-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.py
82 lines (74 loc) · 2.51 KB
/
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
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
num1=int(input("enter the first number-->"))
num2=int(input("enter the second number-->"))
print("we will be using *,-,+,/,%,** -->")
print("press 1 for *")
print("press 2 for /")
print("press 3 for -")
print("press 4 for +")
print("press 5 for %")
print("press 6 for **")
print("press 7 for //")
print("press 8 for &")
print("press 9 for |")
print("press 10 for ~")
ch=int(input("enter your choice-->"))
if (ch==1):
c=num1*num2
print("the solution of the equation",num1 ,"*",num2,"is",c)
elif (ch==4):
c=num1+num2
print("the solution of the equation",num1,'+',num2,'is',c)
elif (ch==3):
print(" press 1 for",num1,'-',num2 ,' or press 2 for ',num2,'-',num1)
y=int(input("-->"))
if (y==1):
c=num1-num2
print("the solution of the equation",num1,'-',num2,'is',c)
elif (y==2):
c=num2-num1
print("the solution of the equation",num2,'-',num1,'is',c)
elif (ch==2):
print(" press 1 for",num1,'/',num2 ,' or press 2 for ',num2,'/',num1)
y=int(input("-->"))
if (y==1):
c=num1/num2
print("the solution of the equation ",num1,'/',num2,'is',c)
elif (y==2):
c=num2/num1
print("the solution of the equation",num2,'/',num1,'is',c)
elif (ch==5):
print(" press 1 for",num1,'%',num2 ,' or press 2 for ',num2,'%',num1)
y=int(input("-->"))
if (y==1):
c=num1%num2
print("the solution of the equation ",num1,'%',num2,'is',c)
elif (y==2):
c=num2%num1
print("the solution of the equation",num2,'%',num1,'is',c)
elif(ch==6):
print(" press 1 for",num1,'**',num2 ,' or press 2 for ',num2,'**',num1)
y=int(input("-->"))
if (y==1):
c=num1**num2
print("the solution of the equation ",num1,'**',num2,'is',c)
elif (y==2) :
c=num2**num1
print("the solution of the equation",num2,'**',num1,'is',c)
elif(ch==7):
print(" press 1 for",num1,'//',num2 ,' or press 2 for ',num2,'//',num1)
y=int(input("-->"))
if (y==1):
c=num1//num2
print("the solution of the equation ",num1,'//',num2,'is',c)
elif (y==2) :
c=num2//num1
print("the solution of the equation",num2,'//',num1,'is',c)
elif(ch==8):
c=num1&num2
print("the solution of the equation",num2,'&',num1,'is',c)
elif(ch==9):
c=num1|num2
print("the solution of the equation",num2,'|',num1,'is',c)
elif(ch==10):
c=~(num1)
print("the solution of the equation ~",num1,'is',c)