0
0 комментариев

def calculate():
operation = input(»’
Please type in the math operation you would like to complete:
+ for addition
— for subtraction
* for multiplication
/ for division
»’)
number_1 = int(input(‘enter your first number’))
number_2 = int(input(‘enter your second number’))
#addition
if operation == ‘+’:
print(‘{}+{}=’.format(number_1, number_2))
print(number_1 + number_2)
#subtraction
elif operation == ‘-‘:
print(‘{}-{}=’.format(number_1,number2))
print(number_1-number_2)
#Multiplication
elif operation == ‘*’:
print(‘{}*{}=’.format(number_1,number_2))
print (number_1*number_2)
#Division
elif operation == ‘/’:
print(‘{}/{}=’.format(number_1,number_2))
print (number_1/number_2)
else:
print(‘you have not typed a valid operation, try again’)
calculate ()
def again ():
calc_again = input (»’ Do you want to calculate again?
Please type Y for YES or N for No.»’)
if calc_again == ‘Y’:
calculate()
elif calc_again == ‘N’:
print(‘See you later’)
else:
again()
calculate()


Добавить комментарий