Question 6: List

Sam is preparing for the new school year and needs to buy various school supplies. He wants to track his spending and calculate the total cost, the average cost per item, and the remaining money from his budget. Write a Python program to help Sam with his calculations.

  • Start by asking for Sam’s name and store it in a variable called name.
  • Ask Sam to input his total budget for school supplies and store it in a variable called budget.
  • Create a list called costs to store the cost of each item Sam buys.
  • Ask Sam to input the cost of each item and add it to the list. Repeat this for 5 items.
  • Calculate the total cost by summing all the amounts in the list.
  • Calculate the average cost per item by dividing the total cost by the number of items in the list.
  • Calculate the remaining money by subtracting the total cost from the budget.
  • Print a message that includes Sam’s name, the total cost, the average cost per item, and the remaining money in a friendly sentence.
Write what you are looking for, and press enter to begin your search!