Advertisement
Guest User

Untitled

a guest
May 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. print("Hi, I am Mimi, your personal mathematics bot.")
  2. command = input("How can I help you today? Would you like to add, subtract, multiply or divide? Or maybe I could help you find the average of several numbers? I could even help you make up your shopping list! Please choose one. >")
  3. if command == "add":
  4. print("OK, let's add some numbers.")
  5. input1 = input("Number 1> ")
  6. input2 = input("Number 2> ")
  7. number1 = int(input1)
  8. number2 = int(input2)
  9. result = number1 + number2
  10. output = str(result)
  11. print(input1 + " + " + input2 + " = " + output)
  12. print("Thanks for adding numbers with me. That was fun!")
  13. elif command == "subtract":
  14. print("OK, let's subtract some numbers.")
  15. input1 = input("Number 1> ")
  16. input2 = input("Number 2> ")
  17. number1 = int(input1)
  18. number2 = int(input2)
  19. result = number1 - number2
  20. output = str(result)
  21. print(input1 + " - " + input2 + " = " + output)
  22. print("That was a good workout with numbers!")
  23. elif command == "multiply":
  24. print("OK, let's multiply some numbers.")
  25. input1 = input("Number 1> ")
  26. input2 = input("Number 2> ")
  27. number1 = int(input1)
  28. number2 = int(input2)
  29. result = number1 * number2
  30. output = str(result)
  31. print(input1 + " * " + input2 + " = " + output)
  32. print("That was a good workout with numbers!")
  33. elif command == "divide":
  34. print("OK, let's divide some numbers.")
  35. input1 = input("Number 1> ")
  36. input2 = input("Number 2> ")
  37. number1 = int(input1)
  38. number2 = int(input2)
  39. result = number1 / number2
  40. output = str(result)
  41. print(input1 + " / " + input2 + " = " + output)
  42. print("That was a good workout with numbers!")
  43. elif command == "average":
  44. how_many = input("How many numbers> ")
  45. how_many = int(how_many)
  46. total = 0
  47. for number_count in range(how_many):
  48. number = input("Enter number " + str(number_count + 1) + "> ")
  49. total = total + int(number)
  50. result = total / how_many
  51. print("The average comes out to " + str(result))
  52. print("That was fun!")
  53. elif command == "shopping":
  54. print("OK, then. Time to go shopping!")
  55. shopping = []
  56. cost = 0
  57. how_many = input("How many items will you be needing today? ")
  58. how_many = int(how_many)
  59. for item_number in range(how_many):
  60. item = input("What is item number " + str(item_number + 1)+ "? ")
  61. shopping.append(item)
  62. item_price = float(input("How much is that today? Just enter the price without the dollar sign please. >"))
  63. cost = cost + item_price
  64. print(shopping)
  65. print("Total cost of your shopping today is $" + str(cost))
  66.  
  67.  
  68. else:
  69.  
  70. print("Sorry, I don't understand.")
  71. print("Bye.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement