Question 2: List

Lily receives a weekly allowance from her parents and spends it on various activities. She wants to track her spending and calculate the total spent, the average amount spent per activity, and the remaining balance. Write a Python program to help Lily with her calculations.

  • Start by asking for Lily’s name and store it in a variable called name.
  • Define a list to store the amounts Lily spent on different activities. You can start with an empty list called spending.
  • Ask Lily to input her weekly allowance and store it in a variable called allowance.
  • Ask Lily to input the amount spent on each activity and add it to the list. Repeat this for 5 activities.
  • Calculate the total amount spent by summing all the amounts in the list.
  • Calculate the average amount spent per activity by dividing the total amount spent by the number of activities in the list.
  • Calculate the remaining balance by subtracting the total amount spent from the weekly allowance.
  • Print a message that includes Lily’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!