Make a program classify several readings, repeat the same work for each one, and keep a summary that accounts for available, skipped, and unvisited values.
The previous chapter named four readings separately. That worked while every statement ran once, but it left us repeating the same kind of name and calculation. Here we will keep the readings together and let Python visit them one at a time.
We will begin with questions that have only two answers: true or false. Those answers let a program choose a branch. A loop then applies the choice repeatedly while a total and count make the changing state visible.
The examples stay small enough to trace by hand. You will check exact boundaries, repair loops that stop too early or too late, and distinguish a missing reading from the number zero. By the end, the repeated summary will be ready to become a function in the next chapter.
After this chapter
Evaluate comparison and combined conditions at exact boundary values.
Trace an if, elif, and else chain and explain why one branch is selected.
Use a list and a for loop to classify each available reading and update a total and count.
Trace and repair a while loop by checking its starting state, condition, update, and final false check.
Use None, continue, or break deliberately and account for processed, skipped, and unvisited values.