Question 1: List

Noah is keeping track of his grocery shopping. He bought several items and wants to calculate the total cost, the average cost per item, and the difference between the most expensive and least expensive item. Write a Python program to help Noah with his calculations.

  • Start by asking for Noah’s name and store it in a variable called name.
  • Define a list to store the prices of the items Noah bought. You can start with an empty list called item_prices.
  • Ask Noah to input the price of each item and add it to the list. Repeat this for 5 items.
  • Calculate the total cost by summing all the items in the list.
  • Calculate the average cost per item by dividing the total cost by the number of items in the list.
  • Find the most expensive item in the list and the least expensive item in the list.
  • Calculate the difference between the most expensive and least expensive item.
  • Print a message that includes Noah’s name and the results of the calculations in a friendly sentence.
Write what you are looking for, and press enter to begin your search!