Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This will be a calculator program.
- print("Welcome to the worst calculator application!")
- userName = input("What is your name, stranger? ")
- print("Well, hello there, " + userName + ".")
- choice = input("What would you like to do? Enter 'ADD' for Addition, \
- 'SUB' for Subtraction, 'MULT' for Multiplication, \
- or 'DIV' for Divide, or 'QUIT' to exit the program: ")
- while True:
- # Addition
- if choice.upper() == "ADD":
- num1 = int(input("Enter your first number: "))
- num2 = int(input("Enter your second number: "))
- answer = num1 + num2
- print("")
- print("Your answer to " + str(num1) + " + " + str(num2) + " is " + str(answer) + ".")
- print("")
- # Subtraction
- elif choice.upper() == "SUB":
- num1 = int(input("Enter your first number which will be subtracted: "))
- num2 = int(input("Enter your second numer to subtract " + str(num1) + " by: "))
- answer = num1 - num2
- print("")
- print("Your answer to " + str(num1) + " - " + str(num2) + " is " + str(answer) + ".")
- print("")
- # Multiplication
- elif choice.upper() == "MULT":
- num1 = int(input("Enter your first number: "))
- num2 = int(input("Enter your second numer: "))
- answer = num1 * num2
- print("")
- print("Your answer to " + str(num1) + " * " + str(num2) + " is " + str(answer) + ".")
- print("")
- # Division
- elif choice.upper() == "DIV":
- num1 = int(input("Enter your first number which will be divided: "))
- num2 = int(input("Enter your second numer to divide " + str(num1) + " by: "))
- answer = num1 / num2
- print("")
- print("Your answer to " + str(num1) + " / " + str(num2) + " is " + str(answer) + ".")
- print("")
- # Exit
- elif choice.upper() == "QUIT":
- break
- # Invalid
- else:
- print("Invalid input, please try again")
- choice = input("What would you like to do? Enter 'ADD' for Addition, \
- 'SUB' for Subtraction, 'MULT' for Multiplication, \
- or 'DIV' for Divide, or 'QUIT' to exit the program: ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement