-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathematical_Calculations.py
More file actions
37 lines (30 loc) · 1.11 KB
/
Mathematical_Calculations.py
File metadata and controls
37 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Mohammad Hossein Zehtab
# Advanced_Python_Wednesdays
# Project_01:_Problem01_Mathematical_Calculations
numbers = [2, 6, -2, -80, 7, 19, 302, 1001, 6430, -2341, 3, -7]
# -----------------------------------------------------------------------------
# Summation and number of even nuumbers in the list
count = 0
summation = 0
for number in numbers:
if abs(number) % 2 == 0:
summation += number
count += 1
print(f"There are {count} even number in the list and their summation is\
{summation}")
# -----------------------------------------------------------------------------
# Multiplication of negative numbers of the list
multiplication = 1
for number in numbers:
if number < 0:
multiplication *= number
print(f"\nMultiplication of the negative numbers of the list is {multiplication}")
# -----------------------------------------------------------------------------
# Average of 4 digit numbers of the list
count4 = 0
summ4 = 0
for number in numbers:
if len(str(abs(number))) == 4:
summ4 += number
count4 += 1
print(f"\nAverage of 4 digit numbers of the list is {summ4 / count4}")