Advertisement
gbruce

Untitled

Feb 25th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. def do_calculation():
  2. # Calculation_code
  3. print("Lets " + command + " some numbers. ")
  4. input1 = input("Length >1 ")
  5. input2 = input("Length >2 ")
  6. Length1 = int(input1)
  7. Length2 = int(input2)
  8.  
  9. # Addition
  10. if command == "add" or command == "Add" or command == "Plus" or command == "plus":
  11. result = Length1 + Length2
  12. operator = " + "
  13.  
  14. # Substaraction
  15. elif command == "Subtract" or command == "subtract" or command == "Minus" or command == "minus":
  16. result = Length1 - Length2
  17. operator = " - "
  18.  
  19. # Multiplication
  20. elif command == "Multiply" or command == "multiply" or command == "Times" or command == "times":
  21. result = Length1 * Length2
  22. operator = " * "
  23.  
  24. # Division
  25. elif command == "Divide" or command == "divide":
  26. result = Length1 / Length2
  27. operator = " / "
  28. output = str(result)
  29. print(input1 + operator + input2 + " = " + output)
  30.  
  31. ##############################################################
  32. def Average():
  33. how_many = input("How many numbers would you like to average? ")
  34. how_many = int(how_many)
  35. total = 0
  36. for number_count in range(how_many):
  37. number = input("Enter number" + str(number_count) + "> ")
  38. total = total + int(number)
  39. result = total / how_many
  40. print("The average is = " + str(result))
  41.  
  42. #####################################################################
  43. def total():
  44. how_many = input("How many shopping items do you have? ")
  45. how_many = int(how_many)
  46. shopping = []
  47. count = 0
  48. for item_number in range(how_many):
  49. item = input("what is item number " + str(item_number) + "? ")
  50. shopping.append(item)
  51. count = count + 1
  52. output = str(count)
  53. print("You have " + output + " items in your shopping list")
  54. print(shopping)
  55. def drink():
  56. how_many = input("How many drinks have you had? ")
  57. how_many = int(how_many)
  58. shopping = []
  59. count = 0
  60. for item_number in range(how_many):
  61. item = input("what was drink number " + str(item_number) + "? ")
  62. shopping.append(item)
  63. count = count + 1
  64. output = str(count)
  65. print("You've had " + output + " drinks, and they are ")
  66. print(shopping)
  67. print("** Hic**")
  68.  
  69.  
  70. finished = False
  71. while finished == False:
  72.  
  73. print("Hi, I'm Tricky, your personal bot")
  74. print("OK , so lets get started!")
  75.  
  76. # Ask the user to enter their name
  77. users_name = input("What is your name? ")
  78. print("Hi " + users_name + ", hope your having a great day!")
  79.  
  80. # Ask the user to enter a choice to proceed
  81. command = input("I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? ")
  82.  
  83. # Add
  84. if command == "add" or command == "Add" or command == "Plus" or command == "plus":
  85. do_calculation()
  86.  
  87. # Subtract
  88. elif command == "Subtract" or command == "subtract" or command == "Minus" or command == "minus":
  89. do_calculation()
  90.  
  91. # Multiply
  92. elif command == "Multiply" or command == "multiply" or command == "Times" or command == "times":
  93. do_calculation()
  94.  
  95. #Divide
  96. elif command == "Divide" or command == "divide":
  97. do_calculation()
  98.  
  99. # Average
  100. elif command == "Average" or command == "average" or command == "Ave" or command == "ave":
  101. Average()
  102.  
  103. # Shopping
  104. elif command == "Shopping" or command == "shopping" or command == "Shop" or command == "shop":
  105. total()
  106.  
  107. # Drinking
  108. elif command == "gimme a drink" or command == "Drink" or command == "booze me up" or command == "I'd like a coldie":
  109. drink()
  110.  
  111. # Goodbye
  112. elif command == "Cya" or command == "Bye" or command == "cya" or command == "bye":
  113.  
  114. finished = True
  115. # Correct choice not made
  116. else:
  117. print("Thanks for playing with me!")
  118. print("cya")
  119.  
  120. Hi, I'm Tricky, your personal bot
  121. OK , so lets get started!
  122. What is your name? Gary
  123. Hi Gary, hope your having a great day!
  124. I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? average
  125. How many numbers would you like to average? 3
  126. Enter number0> 3
  127. Enter number1> 4
  128. Enter number2> 5
  129. The average is = 4.0
  130. cya
  131. Hi, I'm Tricky, your personal bot
  132. OK , so lets get started!
  133. What is your name? Gary
  134. Hi Gary, hope your having a great day!
  135. I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? shop
  136. How many shopping items do you have? 5
  137. what is item number 0? bread
  138. what is item number 1? Milk
  139. what is item number 2? butter
  140. what is item number 3? Soap
  141. what is item number 4? Paper
  142. You have 5 items in your shopping list
  143. ['bread', 'Milk', 'butter', 'Soap', 'Paper']
  144. cya
  145. Hi, I'm Tricky, your personal bot
  146. OK , so lets get started!
  147. What is your name? cya
  148. Hi cya, hope your having a great day!
  149. I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? cya
  150. cya
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement