#05 - Calculator
Code
print('-----Calcultor-----\n')
def menu():
num_1=int(input('Enter the first number: '))
num_2=int(input('Enter the second number: '))
while True:
operation=input('Input the operation you want to do\n+\n-\n/\n*\nor enter E for to exit: ')
if operation == '+' or operation == '-' or operation == '/' or operation == '*':
return num_1,num_2,operation
break
elif operation=='E':
exit()
else:
print('Invalid input pleaes try again')
def calc(num_1,num_2,operation):
if operation=='+':
num_3=num_1+num_2
elif operation=='-':
num_3=num_1-num_2
elif operation=='/':
num_3=num_1/num_2
else:
num_3=num_1*num_2
print('The calculation is',num_3)
go_again=input('Do you want to do another calculation (Y/N)').upper()
if go_again=='Y':
def_num_1,def_num_2,def_operation=menu()
calc(def_num_1,def_num_2,def_operation)
elif go_again=='N':
exit()
def_num_1,def_num_2,def_operation=menu()
calc(def_num_1,def_num_2,def_operation)