Shopping List

Write a program that allows a user to enter the name of an item, its price and the quantity bought. The total cost of the shopping list should be calculated and stored as a total. The name of the item, the price and the quantity should be displayed to the user. The total price should then be displayed to the user rounded to one decimal place.

Name of item: Pencil Case
Enter item cost: 3.95
How many were bought: 9
Receipt
Item: Pencil Case - Cost: 3.95 - Quantity: 9
Total:  35.6
get item name from user as string
get item price from user as real
get item quantity from user as integer
calculate the total by multiplying item price by item quantity
concatenate the receipt message for the item
print "Receipt"
print item1 receipt message
print the receipt total
item_name = str(input("Name of item: "))
item_price = float(input("Enter item cost: "))
item_quantity = int(input("How many were bought: "))

total = item_price * item_quantity

item1 = "Item: " + item_name + " - Cost: " + str(item_price) + " - Quantity: " + str(item_quantity)

print("Receipt")
print(item1)
print("Total: ", round(total, 1))
# Get the details of the item from the user
item_name = str(input("Name of item: "))
item_price = float(input("Enter item cost: "))
item_quantity = int(input("How many were bought: "))

# Calculate and assign the total
total = item_price * item_quantity

# Create your item1 message by concatenating the item details
item1 = "Item: " + item_name + " - Cost: " + str(item_price) + " - Quantity: " + str(item_quantity)

# Display the receipt to the user
print("Receipt")
print(item1)
print("Total: ", round(total, 1))

Extension

Extend the program to take in 3 unique items and generate a receipt for all three items.

Name of item 1: Pencil Case
Enter item cost 1: 3.95
How many of item 1 were bought: 9
Name of item 2: Pencil
Enter item 2 cost: .35
How many of item 2 were bought: 27
Name of item 3: Rubber
Enter item 3 cost: 1.00
How many of item 3were bought: 3
Receipt
Item 1: Pencil Case - Cost: 3.95 - Quantity: 9
Item 2: Pencil - Cost: 0.35 - Quantity: 27
Item 3: Rubber - Cost: 1.0 - Quantity: 3
Total:  49.0

Target

You should be able to use the Round predefined function to solve a problem.