Advertisement
EconomicSerg

Calculator in Python

Jan 25th, 2021
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. num1 = input("Enter a number: ")
  2. num2 = input("Enter another number: ")
  3. calculator = input("Enter 'add', 'subtract', 'multiply', or 'divide': ")
  4.  
  5. if calculator == "add":
  6.     result = int(num1) + int(num2)
  7.     print(result)
  8. elif calculator == "subtract":
  9.     result = int(num1) - int(num2)
  10.     print(result)
  11. elif calculator == "multiply":
  12.     result = int(num1) * int(num2)
  13.     print(result)
  14. elif calculator == "divide":
  15.     result = int(num1) / int(num2)
  16.     print(result)
  17. else:
  18.     print("That is not a valid method of math!")
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement