Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. def do_calculation():
  2. print("Let's " + user_command + " some numbers")
  3. input1 = input("Number 1: ")
  4. input2 = input("Number 2: ")
  5. number1 = int(input1)
  6. number2 = int(input2)
  7. if user_command == "add" or user_command == "Add" or user_command == "ADD" or user_command == "plus" or user_command == "+":
  8. result = number1 + number2
  9. elif user_command == "subtract" or user_command == "Subtract" or user_command == "SUBTRACT"or user_command == "minus" or user_command == "-":
  10. result = number1 - number2
  11. output = str(result)
  12. if user_command == "add" or user_command == "Add" or user_command == "ADD" or user_command == "plus" or user_command == "+":
  13. print(input1 + " + " + input2 + " = " + output)
  14. elif user_command == "subtract" or user_command == "Subtract" or user_command == "SUBTRACT"or user_command == "minus" or user_command == "-":
  15. print(input1 + " - " + input2 + " = " + output)
  16.  
  17. finished = False
  18. while finished == False:
  19. print("Hi, I am Marvin, your personal bot.")
  20. print("Let's get started.")
  21.  
  22. # Ask user to enter their name
  23. users_name = input("Can you start by telling me your name? ")
  24. print("Welcome " + users_name + ". It's nice to meet you.")
  25. # Ask user to choose an operation
  26. 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? ")
  27. # Respond and answer question
  28. if user_command == "add" or user_command == "Add" or user_command == "ADD" or user_command == "plus" or user_command == "+":
  29. do_calculation()
  30. elif user_command == "subtract" or user_command == "Subtract" or user_command == "SUBTRACT"or user_command == "minus" or user_command == "-":
  31. do_calculation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement