SHARE
TWEET

Calculator 1.0

iFailedPreK Jul 20th, 2019 (edited) 251 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # This will be a calculator program.
  2.  
  3. print("Welcome to the worst calculator application!")
  4. userName = input("What is your name, stranger? ")
  5. print("Well, hello there, " + userName + ".")
  6. choice = input("What would you like to do? Enter 'ADD' for Addition, \
  7. 'SUB' for Subtraction, 'MULT' for Multiplication, \
  8. or 'DIV' for Divide, or 'QUIT' to exit the program: ")
  9.  
  10. while True:
  11.     # Addition
  12.     if choice.upper() == "ADD":
  13.         num1 = int(input("Enter your first number: "))
  14.         num2 = int(input("Enter your second number: "))
  15.         answer = num1 + num2
  16.         print("")
  17.         print("Your answer to " + str(num1) + " + " + str(num2) + " is " + str(answer) + ".")
  18.         print("")
  19.                          
  20.     # Subtraction
  21.     elif choice.upper() == "SUB":
  22.         num1 = int(input("Enter your first number which will be subtracted: "))
  23.         num2 = int(input("Enter your second numer to subtract " + str(num1) + " by: "))
  24.         answer = num1 - num2
  25.         print("")
  26.         print("Your answer to " + str(num1) + " - " + str(num2) + " is " + str(answer) + ".")
  27.         print("")
  28.  
  29.     # Multiplication
  30.     elif choice.upper() == "MULT":
  31.         num1 = int(input("Enter your first number: "))
  32.         num2 = int(input("Enter your second numer: "))
  33.         answer = num1 * num2
  34.         print("")
  35.         print("Your answer to " + str(num1) + " * " + str(num2) + " is " + str(answer) + ".")
  36.         print("")
  37.  
  38.     # Division
  39.     elif choice.upper() == "DIV":
  40.         num1 = int(input("Enter your first number which will be divided: "))
  41.         num2 = int(input("Enter your second numer to divide " + str(num1) + " by: "))
  42.         answer = num1 / num2
  43.         print("")
  44.         print("Your answer to " + str(num1) + " / " + str(num2) + " is " + str(answer) + ".")
  45.         print("")
  46.  
  47.     # Exit
  48.     elif choice.upper() == "QUIT":
  49.         break
  50.    
  51.     # Invalid
  52.     else:
  53.         print("Invalid input, please try again")
  54.  
  55.     choice = input("What would you like to do? Enter 'ADD' for Addition, \
  56. 'SUB' for Subtraction, 'MULT' for Multiplication, \
  57. or 'DIV' for Divide, or 'QUIT' to exit the program: ")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top