Advertisement
mellis74

bot

Feb 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. print("Hi, i am your personal bot. lets get started")
  2. user_name = input("What is your name? ")
  3. print("Welcome " + user_name)
  4. command = input("How can I help? ")
  5. if command == "add":
  6.   print("Lets add some numbers")
  7.   input1 = input("number 1> ")
  8.   input2 = input("number 2> ")
  9.   number1 = int(input1)
  10.   number2 = int(input2)
  11.   result = number1 + number2
  12.   print(input1 + " + " + input2 + " = " + str(result))
  13. elif command == "subtract":
  14.   print("Lets 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.   print(input1 + " - " + input2 + " = " + str(result))
  21.  
  22. elif command == "average":
  23.   how_many = input("How many numbers? ")
  24.   how_many = int(how_many)
  25.   total = 0
  26.   for number_count in range(how_many):
  27.     number = input("Enter number " + str(number_count) + "> ")
  28.     total = total + int(number)
  29.   result = total / how_many
  30.   print("the average = " + str(result))
  31.  
  32. elif command == "shopping":
  33.   shopping = []
  34.   price_total = 0
  35.   how_many2 = input("How many items do you need? ")
  36.   how_many2 = int(how_many2)
  37.   for item_numbers in range(how_many2):
  38.     item = input("What is the item name " + str(item_numbers) + " ?")
  39.     shopping.append(item)
  40.     cost = input("What is the price for " + str(item) + "? ")
  41.     shopping.append(cost)
  42.     price_total = price_total + float(cost)
  43.   discount = input("Enter the discount? ")
  44.   discount_real = float(int(discount)/100)
  45.   discount_final = float(price_total * discount_real)
  46.   price_final = float(discount_final)
  47.   print(shopping)
  48.   print("The total price of the items before discount is " + str(price_total))
  49.   print("The total price of the items after discount is " + str(price_final))
  50.  
  51. else:
  52.   print("Sorry, i don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement