crzcas

bot with shopping

Dec 3rd, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.26 KB | None | 0 0
  1. import math
  2.  
  3. print("Hi, I am Marvin, your personal bot.")
  4. print("You can select one word of the menu, writing the word")
  5. print("add   subtract   multiply   divide   volume   average   shopping")
  6. command = input("How can I help? ")
  7.  
  8. if command == "add" or command == "plus":   # Adding code to add in lines 8-16    
  9.     print("lets add two numbers")
  10.     input1 = input("Number 1> ")
  11.     input2 = input("Number 2> ")
  12.     number1 = float(input1)
  13.     number2 = float(input2)
  14.     result = number1 + number2
  15.     output = str(result)
  16.     print(input1 + " + " + input2 + " = " + output)
  17.    
  18. elif command == "subtract":   # Adding code to subtract in lines 18-26  
  19.     print("lets subtract two numbers")
  20.     input1 = input("Number 1> ")
  21.     input2 = input("Number 2> ")
  22.     number1 = float(input1)
  23.     number2 = float(input2)
  24.     result = number1 - number2
  25.     output = str(result)
  26.     print(input1 + " - " + input2 + " = " + output)
  27.    
  28. elif command == "multiply" or command == "multiplication":   # Adding code to multiply in lines 28-36  
  29.     print("lets multiply two numbers")
  30.     input1 = input("Number 1> ")
  31.     input2 = input("Number 2> ")
  32.     number1 = float(input1)
  33.     number2 = float(input2)
  34.     result = number1 * number2
  35.     output = str(result)
  36.     print(input1 + " * " + input2 + " = " + output)
  37.  
  38. elif command == "divide" or command == "division":   # Adding code to divide in lines 38-46  
  39.     print("lets divide two numbers")
  40.     input1 = input("Number 1> ")
  41.     input2 = input("Number 2> ")
  42.     number1 = float(input1)
  43.     number2 = float(input2)
  44.     result = number1 / number2
  45.     output = str(result)
  46.     print(input1 + " / " + input2 + " = " + output)  
  47.  
  48. elif command == "Volume" or command == "volume":   # Adding code to volume in lines 48-57  
  49.     print("lets calculate volume of cylinder with 2 values, ratio and high in cms.")
  50.     input1 = input("ratio > ")
  51.     input2 = input("high > ")
  52.     ratio = float(input1)
  53.     high = float(input2)
  54.     #pi1 = 3.14
  55.     result = math.pi * ratio * ratio * high
  56.     output = str(result)
  57.     print("volume of cylinder = " + output + " cms^3")    
  58.    
  59. elif command == "average" or command == "Average":   # Adding code to average in lines 59-68  
  60.     print("lets calculate the average of some numbers!")
  61.     how_many = input("How many numbers>")
  62.     how_many = int(how_many)
  63.     total = 0
  64.     for number_count in range(how_many):
  65.         number = input("Enter number " + str(number_count) + ">")
  66.         total = total + int(number)
  67.     result = total/ how_many
  68.     print("the average = " + str(result))
  69.    
  70. elif command == "shopping" or command == "Shopping":   # Adding code to shopping in lines 70-84
  71.     shopping = []
  72.     how_many = input("how many items of shopping do you have? ")
  73.     how_many = int(how_many)
  74.     total = 0
  75.     for item_number in range (how_many):
  76.         item = input("What is the number " + str(item_number) + "? ")
  77.         shopping.append(item)
  78.         total = total + float(item)
  79.     print(shopping)
  80.     print("Total shopping = " + str(total))
  81.  
  82.     for item in shopping:
  83.         print(item)
  84.     print("You have " + str(len(shopping)) + " items in your shopping list" + " and the total shopping is = " + str(total))
  85.  
  86. else:
  87.     print("sorry I dont understand")
  88.  
Advertisement
Add Comment
Please, Sign In to add comment