-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaculator.py
More file actions
31 lines (30 loc) · 868 Bytes
/
caculator.py
File metadata and controls
31 lines (30 loc) · 868 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
def add():
print("sum of",a,"and",b,"is: ",a+b)
def diff():
if a>b:
print("difference of",a,"and",b,"is: ",a-b)
else:
print("difference of",a,"and",b,"is: ",b-a)
def multipy():
print("multiplication f",a,"and",b,"is: ",a*b)
def div():
if a==0 or b==0:
print("division not possible")
print("division of",a,"and",b,"is: ",a/b)
else:
print("division of",a,"and",b,"is: ",a/b)
print('1.to add 2 number \n 2.to subtract 2 numbers\n 3. to multipy 2 number \n 4. divide 2 numbers \n 5. exit')
a=float(input('enetr number'))
b=float(input('enter number'))
while True:
ch=int(input("enter function you want to perform"))
if ch==1:
add()
elif ch==2:
diff()
elif ch==3:
multiply()
elif ch==4:
div()
else:
break