import os
def clear():
os.system('cls')
def Calc_Sum(num1 , num2):
return (num1+num2)
def Calc_Minus(num1 , num2):
return (num1-num2)
def Calc_Multiplication(num1 , num2):
return num1 * num2
def Calc_Division(num1 , num2):
return num1 / num2
def check_int_number(number_int):
'''This function is to check the input that the number must be entered'''
while True:
if number_int.isalpha() :
print('pls enter input number')
number_int=input('pls enter again : ')
elif int(number_int)<1:
print('Please enter a number other than zero')
number_int=input(' pls enter input again : ')
else:
return int(number_int)
def input_operator(operator):
while True:
if operator == '+':
return Calc_Sum(user_input1,user_input2)
elif operator =='-':
return Calc_Minus(user_input1,user_input2)
elif operator == '*':
return Calc_Multiplication(user_input1,user_input2)
elif operator =='/':
return Calc_Division(user_input1,user_input2)
else:
print('The operator you entered is incorrect !!!')
operator=input('Please choose one of the opposite operators (- * / +)')
continue
user_input1 = check_int_number((input('Please enter your first number : ')))
user_operator=input('Please choose one of the opposite operators (- * / +): ')
user_input2 = check_int_number((input('Please enter your second number : ')))
clear()
print(f' your answer : {input_operator(user_operator)}')