Advertisement
Michael_J_T

Untitled

Aug 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. def do_calculation():
  2. print("lets " + command + " some numbers")
  3. input1 = input("Number 1>")
  4. input2 = input("Number 2>")
  5. number1 = int(input1)
  6. number2 = int(input2)
  7. if command == "add":
  8. result = number1 + number2
  9. elif command == "subtract":
  10. result = number1 - number2
  11. elif command == "multiply":
  12. result = number1 * number2
  13. if command == "add":
  14. print(str(input1) + " + " + str(input2) + " = " + str(result))
  15. elif command == "subtract":
  16. print(str(input1) + " - " + str(input2) + " = " + str(result))
  17. elif command == "multiply":
  18. print(str(input1) + " * " + str(input2) + " = " + str(result))
  19.  
  20. ### Welcome ###
  21. print ("Hi, I am Albert, your personal bot.")
  22. users_name = input("What is your name?")
  23. print ("Welcome, " + users_name)
  24. ### Seleect Math Operation ###
  25. finished = False
  26. while finished == False:
  27. print ("I can do any of the following tasks for you: add two numbers, subtract numbers, or multiply numbers.")
  28. command = input("Type 'add', 'subtract', 'multiply' or 'end' to finish.")
  29. ### Perform Calculation ###
  30. if command == "add":
  31. do_calculation()
  32. elif command == "subtract":
  33. do_calculation()
  34. elif command == "multiply":
  35. do_calculation()
  36. ### End Program ###
  37. elif command == "end":
  38. finished = True
  39.  
  40. print ("Thanks for using my smarts to help. Bye for now")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement