Advertisement
Roddyn

bot_calculate change

Dec 18th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. total = 0
  2. meal_total=0
  3. cash=0
  4.  
  5. print("Hi, I am Marvin, your personal bot.")
  6.  
  7. #asks and prints users name
  8. user_name = input ("What is your name? ")
  9. print("Welcome " + user_name )
  10.  
  11. #input a calculation type
  12. command = input("How can I help? ")
  13.  
  14. #when input add does an addition calculation
  15. if command == "add":
  16. print("let's add some numbers")
  17. input1 = input("Number 1> ")
  18. input2 = input("Number 2> ")
  19. number1 = int(input1)
  20. number2 = int(input2)
  21. result = number1 + number2
  22. output = str(result)
  23. print(input1 + " + " + input2 + " = " + output)
  24.  
  25. #when input subtract does a suntraction calculation
  26. elif command == "subtract":
  27. print("let's subtract some numbers")
  28. input1 = input("Number 1> ")
  29. input2 = input("Number 2> ")
  30. number1 = int(input1)
  31. number2 = int(input2)
  32. result = number1 - number2
  33. output = str(result)
  34. print(input1 + " - " + input2 + " = " + output)
  35.  
  36. #when input multiply does a multiply calculation
  37. elif command == "multiply":
  38. print("let's Multiply some numbers")
  39. input1 = input("Number 1> ")
  40. input2 = input("Number 2> ")
  41. number1 = int(input1)
  42. number2 = int(input2)
  43. result = number1 * number2
  44. output = str(result)
  45. print(input1 + " * " + input2 + " = " + output)
  46.  
  47. #when input subtract does asubtraction calculation
  48. elif command == "subtract":
  49. print("let's subtract some numbers")
  50. input1 = input("Number 1> ")
  51. input2 = input("Number 2> ")
  52. number1 = int(input1)
  53. number2 = int(input2)
  54. result = number1 - number2
  55. output = str(result)
  56. print(input1 + " - " + input2 + " = " + output)
  57.  
  58. #when input triangle calculates the are of a right angled triangle
  59. elif command == "triangle":
  60. print("let's find the area of a right angled triangle")
  61. input1 = input("Base of the triangle> ")
  62. input2 = input("Height of the triangle> ")
  63. number1 = int(input1)
  64. number2 = int(input2)
  65. result = (number1 * 0.5) * number2
  66. output = str(result)
  67. print("(" + input1 + " * 0.5) *" + input2 + " = " + output)
  68. # if neither add or subtract outputs an apology
  69. elif command == "average":
  70. how_many = input("How many numbers> ")
  71. how_many = int(how_many)
  72. for number_count in range(how_many):
  73. number = input("Enter number " + str(number_count) + "> ")
  74. total = total + int(number)
  75. result = total / how_many
  76. print("the average = " + str(result))
  77. elif command == "change":
  78. meal = []
  79. count= 0
  80. meal_items=int(input("How many items in your meal list?" ))
  81.  
  82.  
  83. for item_number in range(meal_items):
  84. item = int(input("How much was your first item? " + str(meal_items)+""))
  85. meal.append(item)
  86. count= count +1
  87. meal_total=int(meal_total)+int(item)
  88.  
  89.  
  90. output = str(count)
  91.  
  92. print(meal)
  93.  
  94. print("You have spent " + str(meal_total) + " on your meal.")
  95.  
  96. cash= int(input("How much cash have you given?"))
  97.  
  98. leftover = int(cash)-int(meal_total)
  99. print(("You should receive $" +str(leftover)+" in your change!"))
  100.  
  101.  
  102. else:
  103. print ("sorry I can't do that yet!!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement