-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmetics.py
More file actions
40 lines (35 loc) · 924 Bytes
/
Copy pathArithmetics.py
File metadata and controls
40 lines (35 loc) · 924 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
count = 1
while count < 3:
#Input x and y
x = float(input("Enter x: "))
y = float(input("Enter y: "))
#Choose mode of operation
print("Choose operation: + - * / % ** //")
opr = input("Operation: ")
if opr == "+":
result = x + y
elif opr == "-":
result = x - y
elif opr == "*":
result = x * y
elif opr == "/":
if y == 0:
result = "Error: Division by zero!"
else:
result = x / y
elif opr == "%":
if y == 0:
result = "Error: Division by zero!"
else:
result = x % y
elif opr == "**":
result = x ** y
elif opr == "//":
if y == 0:
result = "Error: Division by zero!"
else:
result = x // y
else:
result = "Invalid operation!"
print("Result:", result)
count += 1