-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalculator.py
37 lines (28 loc) · 868 Bytes
/
calculator.py
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
while True:
print("1 Addition")
print("2 Subtraction")
print("3 Multiplication")
print("4 Modulus")
print("5 Division")
print("6 Enter q or Q to Exit")
choice = input("Enter your choice : ")
if choice == 'q' or choice == 'Q':
break
num1 = float(input("Enter Number 1 : "))
num2 = float(input("Enter Number 2 : "))
if choice == "1":
print(num1, "+", num2, "=", (num1+num2))
elif choice == "2":
print(num1, "-", num2, "=", (num1-num2))
elif choice == "3":
print(num1, "*", num2, "=", (num1*num2))
elif choice == "4":
print(num1, "%", num2, "=", (num1%num2))
elif choice == "5":
if num2 == 0.0:
print("Divide by 0 Error")
else:
print(num1, "/", num2, "=", (num1/num2))
else:
print("Invalid Choice")
print()