-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiff-operations.py
executable file
·53 lines (36 loc) · 1.12 KB
/
diff-operations.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
import time
print("Hi, Welcome to Quantum Tricks")
time.sleep(1.0)
print("This a different operations calculator using same numbers")
time.sleep(2.0)
print("Lets start calculating")
time.sleep(1.0)
num1 = int(input("Enter an integer:"))
num2 = int(input("Enter an integer:"))
# Calculating addition
def add(a, b):
return a + b
# Calculating subtraction
def sub(a, b):
return a - b
# Calculating multiplication
def mul(a, b):
return a * b
# Calculating division
def div(a, b):
return a / b
# Calculating exponent
def power(a, b):
return a ** b
# Calculating mod
def mod(a, b):
return a % b
ops = {"+": add, "add": add, "addition": add, "sum": add, "-": sub, "sub": sub, "subtraction": sub, "difference": sub, "x": mul,
"multiply": mul, "*": mul, "multiplication": mul, "div": div, "division": div, "/": div, "power": power, "^": power,
"**": power, "mod": mod, "%": mod, "||": mod, "| |": mod, }
while True:
op = input("Enter an operation:")
if op.lower() in ops:
print(eval("ops[op](num1, num2)"))
else:
print("Sorry operation does not exists. Please try again")