-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.py
More file actions
38 lines (27 loc) · 838 Bytes
/
Copy pathcalc.py
File metadata and controls
38 lines (27 loc) · 838 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
num_1=int(input("Enter 1st Number: "))
num_2=int(input("Enter 2nd Number: "))
operation=input("Select + or - or * or / or ** or ! (factorial) or absolute or | (OR) or & (AND) or ^ (XOR): ")
result=0
if operation=="+": #Addition
result=num_1+num_2
elif operation=="-": #Subtraction
result=num_1-num_2
elif operation=="*": #Multiplication
result=num_1*num_2
elif operation=="/": #Division
result=num_1/num_2
elif operation=="**": #Power
result=num_1**num_2
elif operation=="!": #Factorial
result=1
for i in range(1,num_1+1):
result=result*i
elif operation=="absolute": #Absolute
result=abs(num_1)
elif operation=="|": #OR
result=num_1|num_2
elif operation=="&": #AND
result=num_1 & num_2
elif operation=="^": #XOR
result=num_1 ^ num_2
print("Result is:", result)