The Week in Numbers
Time for another project! This checkpoint puts the lists and loops from the last two lessons to work, together with everything you learned before them. As in the first checkpoint, the instructions say what the program should print, and how you write it is up to you. And as there, each exercise also runs your program with other data, so it has to work everything out from the list.
The project. A fitness band counts your steps. Over three exercises, your program will turn a week of its data into a report: the total, the average and the best day, how often you reached your daily goal, and finally a chart.
The data. The variable week is a list with one element for each day. Each element is a nested list of two values: the name of the day and the number of steps. week[0] is ["Mon", 6200], so week[0][0] is "Mon" and week[0][1] is 6200. The list is written on several lines to make it easier to read. Python doesn't mind: the list goes on until its closing bracket.
The task. For this week, the report starts like this:
Total: 63000 steps
Average: 9000.0 steps a day
Best day: Sat (15800 steps)The average is the total divided by the number of days. Get the number of days from the list, don't write 7 into your code: then the program stays right when the band adds another day. And print each line only once, after the loop has gone through the whole week.
When your program works, try changing the steps of a day, or add an eighth day to the list, and check the report again. The exercise does that too.
Instructions
Print the total number of steps and the average per day.
Print the best day: its name and its number of steps.
Start programming for free
1/3