Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- print("Let's " + user_command + " some numbers")
- input1 = input("Number 1: ")
- input2 = input("Number 2: ")
- number1 = int(input1)
- number2 = int(input2)
- if user_command == "add" or user_command == "Add" or user_command == "ADD" or user_command == "plus" or user_command == "+":
- result = number1 + number2
- elif user_command == "subtract" or user_command == "Subtract" or user_command == "SUBTRACT"or user_command == "minus" or user_command == "-":
- result = number1 - number2
- output = str(result)
- if user_command == "add" or user_command == "Add" or user_command == "ADD" or user_command == "plus" or user_command == "+":
- print(input1 + " + " + input2 + " = " + output)
- elif user_command == "subtract" or user_command == "Subtract" or user_command == "SUBTRACT"or user_command == "minus" or user_command == "-":
- print(input1 + " - " + input2 + " = " + output)
- finished = False
- while finished == False:
- print("Hi, I am Marvin, your personal bot.")
- print("Let's get started.")
- # Ask user to enter their name
- users_name = input("Can you start by telling me your name? ")
- print("Welcome " + users_name + ". It's nice to meet you.")
- # Ask user to choose an operation
- user_command = input("What do you want to add, subtract, multiply, divide, find the perimeter of a rectangle, find an average, or create a shopping list? ")
- # Respond and answer question
- if user_command == "add" or user_command == "Add" or user_command == "ADD" or user_command == "plus" or user_command == "+":
- do_calculation()
- elif user_command == "subtract" or user_command == "Subtract" or user_command == "SUBTRACT"or user_command == "minus" or user_command == "-":
- do_calculation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement