-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCalculator.py
39 lines (34 loc) · 983 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
print("CALCULATOR")
print('''1.SUM
2.SUB
3.MULTI
4.DIV
5.REM
7.ABS
6.EXPO (first number is the number and second number is the exponent to raised)''')
operation = input("Enter the operation: ").lower()
first = int(input("Enter the first number: "))
second = int(input("Enter the second number: "))
SUM = lambda a,b : a+b
SUB = lambda a,b : a-b
MULTI = lambda a,b : a*b
DIV = lambda a,b : a/b
REM = lambda a,b : a%b
ABS = lambda a : abs(a)
EXPO = lambda a,b : a**b
if operation == "sum":
print("Result = ",SUM(first,second))
elif operation == "sub":
print("Result = ",SUB(first,second))
elif operation == "multi":
print("Result = ",MULTI(first,second))
elif operation == "div":
print("Result = ",DIV(first,second))
elif operation == "rem":
print("Result = ",REM(first,second))
elif operation == "abs":
print("Result = ",ABS(first),",",abs(second))
elif operation == "expo":
print("Result = ",EXPO(first,second))
else:
print("Inout not valid")