Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # I will include the shopping list creator into my bot
- print("Hi, I am Eley, your personal bot.")
- question1 = input("Do you want to chat with me?")
- print(question1)
- print("Let’s get started")
- users_name = input("What is your name? ")
- print(users_name)
- print("Nice to meet you " + users_name + ", welcome.")
- shopping = [] # Let's create an empty list variable
- how_many = input("How many items of shopping are needed? ")
- how_many = int(how_many)
- for item_number in range(how_many): # Let's add a "for" loop with a range to loop x times
- item = input("What is item number " + str(item_number) + "? ") #
- shopping.append(item) # Let's append item to the list
- print(shopping) # After the "for" loop let’s print the lista
- # Another way to show a total at the end
- print "The items in my shopping account are",len (shopping)
- count = 0
- for item in shopping:
- print(item)
- count = count + 1 # Counter
- print(count)
- # Add up the cost of your shopping
- command = input("Let's calculate the cost of your shopping, select add/plus, average, discount, divide: ")
- if command == "add" or command == "plus":
- result = how_many
- output = str(result)
- print("The items in my shopping account are " + output)
- how_many = input("Please re-enter the number of items from your shopping list > ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter the price of each item " + str(number_count) + "> ")
- total = total + int(number)
- result = total
- print("The sum of all items of shopping account = " + str(result) + " €")
- # Average the cost of your shopping
- elif command == "average":
- result = how_many
- output = str(result)
- print("The items in my shopping account are " + output)
- how_many = input("Please re-enter the number of items from your shopping list > ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter the price of each item " + str(number_count) + "> ")
- total = total + int(number)
- result = total / how_many
- print("The average of all items of shopping account = " + str(result) + " €")
- # Calculate a discount from the shopping list:
- # 1 Divide the discount percentage by 100 to convert it to a decimal. Eg: If the discount we want to calculate is 40%,
- # you must divide 40/100 = 0.4
- # 2 Multiply the discount converted to a decimal by the original price, in this way you will be able to find the discount
- # percentage.
- # Eg: If the original price is € 120, the operation to be performed will be 120 x 0.4 = € 48
- # 3 Subtract from the original price the discount amount we have obtained. Eg: If € 48 is the 40% discount of € 120, to
- # find the final price we must subtract the amount less than the highest: 120-48 = € 72
- elif command == "discount":
- result = how_many
- output = str(result)
- print("The items in my shopping account are " + output)
- how_many = input("Please re-enter the number of items from your shopping list > ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter the price of each item " + str(number_count) + "> ")
- total = total + int(number)
- result = total
- discount = input("Please enter the discount of shopping account > ")
- percent = int(discount)
- #number = int(100)
- result1 = percent / 100
- result2 = result1 * result
- substract = result - result2
- print("The discount of all items of shopping account = " + str(substract) + " €")
- else:
- print("Sorry, because your answer is wrong, the chat is over.")
Add Comment
Please, Sign In to add comment