Question 7: List

Sophie is planning her meals for the week and wants to track the total calories consumed, the average calories per meal, and the difference between the most caloric meal and the least caloric meal. Write a Python program to help Sophie with her calculations.

  • Start by asking for Sophie’s name and store it in a variable called name.
  • Define a list to store the calories of each meal. You can start with an empty list called calories.
  • Ask Sophie to input the calories of each meal and add it to the list. Repeat this for 7 meals (one for each day of the week).
  • Calculate the total calories consumed by summing all the calories in the list.
  • Calculate the average calories per meal by dividing the total calories by the number of meals in the list.
  • Find the maximum calories in the list (most caloric meal) and the minimum calories in the list (least caloric meal).
  • Calculate the difference between the maximum and minimum calories.
  • Print a message that includes Sophie’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!