-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator_def.py
More file actions
34 lines (31 loc) · 1.06 KB
/
Copy pathcalculator_def.py
File metadata and controls
34 lines (31 loc) · 1.06 KB
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
def calculator():
while True:
fri_no=int(input("enter a number"))
while True:
print(f"\nm{"+","-","*","/"}")
pick=input("pick an operation: ")
se_no=int(input(" enter next number: "))
if pick=="+":
c=fri_no+se_no
elif pick == "-":
c=fri_no-se_no
elif pick == "*":
c= fri_no*se_no
elif pick == "/":
if se_no!=0:
c=fri_no/se_no
else:
print("error:in division by zero is not alloed")
else:
print("invalid operation . please choose a valid operation.")
print(f" result:{c}")
choise=input("enter 'y' to continue calculation with {c} or'n' to start to 'e' exit:")
if choise=='y':
fri_no = c
elif choise=="n":
break
elif choise == "e":
return
else:
print( "invalid choice")
print(calculator())