def  help_screen():
 print("Add: Add two numbers")
 print("subtract: subtract two numbers")
 print("multiplication: multiple two numbers")
 print("divsion: divide two numbers")
 print("print: display the result of latest operation")
 print("help: display help screen")
 print("quit: exit the program")
def menu():
 return input("A(add S(ubtract M(ultiple D(ivide P(rint H(elp Q(uit")
 
result = 0.0
first_num = 0.0
second_num = 0.0
def get_input():
 global first_num, second_num
 first_num = float(input("first figure:"))
 second_num = float(input("second figure:"))
 
def report():
 print(result)
def add():
 global result
 result = first_num +  second_num
def subtract():
 global result
 result = first_num -  second_num
 
def multiply():
 global result
 result = first_num *  second_num
 
 
def divide():
 global result
 result = first_num /  second_num
           
def main():
 done = False;
 while not done:
  choice = menu()
  if choice == 'A' or choice == 'a':
   get_input()
   add()
   report()
  elif choice == 'S' or choice == 's':
   get_input()
   subtract()
   report()
  elif choice == 'M' or choice == 'm':
   get_input()
   multiply()
   report()
  elif choice == 'D' or choice == 'd':
   get_input()
   divide()
   report()
  elif choice == 'P' or choice == 'p':
   report()
  elif choice == 'H' or choice == 'h':
   help_screen() 
    
  elif choice == 'Q' or choice == 'q':
   done = True
main() 
NOTE: Dont forget indenting the above code
GOOD LUCK

Comments
Post a Comment