Advertisement
182days

Calculator

May 10th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #python calculator
  2. #steve basford 2015
  3. def add():
  4.     answer = (num1) + (num2)
  5.     print (answer)
  6. def subtract():
  7.     answer = (num1) - (num2)
  8.     print (answer)
  9. def divide():
  10.     if num1 == "0"
  11.     answer = (num1) / (num2)
  12.     print (answer)
  13. def multiply():
  14.     answer = (num1) * (num2)
  15.     print (answer)
  16. print("Welcome to my very first calculator!")
  17. choice = input("(A)ddition (S)ubtraction (D)ivision (M)ultiplication")
  18. num1 = int(input("Enter the first number"))
  19. num2 = int(input("Enter the second number"))
  20. if choice == "a":
  21.     add()
  22. elif choice == "s":
  23.     subtract()
  24. elif choice == "d":
  25.     divide()
  26. elif choice == "m":
  27.     multiply()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement