Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calculate(firstOperand, secondOperand, operand):
- if operand == '+':
- print(int(firstOperand) + int(secondOperand))
- elif operand == '-':
- print(int(firstOperand) - int(secondOperand))
- elif operand == '*':
- print(int(firstOperand) * int(secondOperand))
- elif operand == '/':
- print(int(firstOperand) / int(secondOperand))
- else:
- print("Invalid input. Try again\n")
- menu()
- def menu():
- print("\nWelcome to the calculator program")
- print("Please enter your operands and operator")
- firstOperand = raw_input("\nFirst operand:")
- secondOperand = raw_input("\nSecond operand:")
- operand = raw_input("\n Operand:")
- return (firstOperand, secondOperand, operand)
- (firstOperand, secondOperand, operand) = menu()
- calculate(firstOperand, secondOperand, operand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement