-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleCalculator.py
85 lines (77 loc) · 2.11 KB
/
SimpleCalculator.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def Sum():
x = float(input("Enter the first number: "))
y = float(input("Enter the second number: "))
z = x + y
print("Solution is:",z)
def Multiply():
x = float(input("Enter the first number: "))
y = float(input("Enter the second number: "))
z = x * y
print("Solution is:",z)
def Divide():
x = float(input("Enter the first number: "))
y = float(input("Enter the second number: "))
z = x / y
print("Solution is:",z)
def Subtract():
x = float(input("Enter the first number: "))
y = float(input("Enter the second number: "))
z = x - y
print("Solution is:",z)
def FloorDivide():
x = float(input("Enter the first number: "))
y = float(input("Enter the second number: "))
z = x // y
print("Solution is:",z)
def Modulo():
x = float(input("Enter the first number: "))
y = float(input("Enter the second number: "))
z = x % y
print("Solution is:",z)
def Power():
x = float(input("Enter the number: "))
y = int(input("Enter power: "))
z = x ** y
print("Solution is:",z)
def SquareRoot():
x = float(input("Enter the number: "))
y = x ** 0.5
print("Solution is:",y)
#__main__
while True:
print("--------------------")
print(" Calculator ")
print("--------------------")
print(" 1.Addition ")
print(" 2.Subraction ")
print(" 3.Multiplicatiion ")
print(" 4.Division ")
print(" 5.Floor division ")
print(" 6.Modulus division ")
print(" 7.Power ")
print(" 8.Square Root ")
print(" 9.Exit ")
print("--------------------")
choice = int(input("Enter your choice: "))
print("--------------------")
if choice == 1:
Sum()
elif choice == 2:
Subtract()
elif choice == 3:
Multiply()
elif choice == 4:
Divide()
elif choice == 5:
FloorDivide()
elif choice == 6:
Modulo()
elif choice == 7:
Power()
elif choice == 8:
SquareRoot()
elif choice == 9:
print("Goodbye!")
break
else:
print("Given option not valid.")