-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_opearations.py
More file actions
57 lines (35 loc) · 956 Bytes
/
math_opearations.py
File metadata and controls
57 lines (35 loc) · 956 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
numbers = []
while True:
print("Choose what you want to do")
print("Press 1 for Addition")
print("Press 2 for Subtraction")
print("Press 3 for Multiplication")
print("Press 4 for Division")
t = int(input(":"))
if t > 0 and t < 5:
break
answer = 0
while True:
el = int(input("Enter positive elements: "))
if el > 0:
break
for i in range(el):
num = float(input(f"Enter number {i + 1} : "))
numbers.append(num)
answer = numbers[0]
if t == 1:
for j in range(len(numbers)-1):
answer += numbers[j + 1]
print(f"Answer:{answer}")
elif t == 2:
for j in range(len(numbers)-1):
answer -= numbers[j + 1]
print(f"Answer:{answer}")
elif t == 3:
for j in range(len(numbers)-1):
answer *= numbers[j + 1]
print(f"Answer:{answer}")
elif t == 4:
for j in range(len(numbers)-1):
answer /= numbers[j + 1]
print(f"Answer:{answer}")