Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. def calculate(firstOperand, secondOperand, operand):
  2.         if operand == '+':
  3.                 print(int(firstOperand) + int(secondOperand))
  4.         elif operand == '-':
  5.                 print(int(firstOperand) - int(secondOperand))
  6.         elif operand == '*':
  7.                 print(int(firstOperand) * int(secondOperand))
  8.         elif operand == '/':
  9.                 print(int(firstOperand)  / int(secondOperand))
  10.         else:
  11.                 print("Invalid input. Try again\n")
  12.                 menu()
  13.  
  14. def menu():
  15.         print("\nWelcome to the calculator program")
  16.         print("Please enter your operands and  operator")
  17.         firstOperand = raw_input("\nFirst operand:")
  18.         secondOperand = raw_input("\nSecond operand:")
  19.         operand = raw_input("\n Operand:")
  20.         return (firstOperand, secondOperand, operand)
  21.  
  22. (firstOperand, secondOperand, operand) = menu()
  23.  
  24. calculate(firstOperand, secondOperand, operand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement