Section 7.3 Flow of Execution of the while Loop
As before with
if
, loops allow us as programmers to manipulate the control flow of a Python program. We can now possibly skip a portion of code, or choose to repeat it an indefinite number of times.The flowchart below provides the general sequence of steps that govern execution of a while loop.
A codelens demonstration is a good way to help you visualize exactly how the flow of control works with the while loop. Try stepping forward and backward through the program by pressing the buttons. You can see the value of
count
change as the loop iterates through the values from 10 to 0.You have attempted of activities on this page.