
Dancing with Python
By :

When you write code, you create instructions for a computer that state what steps the computer must take to accomplish some task. In that sense, you are specifying a recipe. Depending on some conditions, like if a bank balance is positive or a car’s speed exceeds a stated limit, the sequence of steps may vary. We call how your code moves from one step to another its flow.
Let’s make some bread to show where a basic recipe has points where we should make choices.
I call that a “straight-through” recipe because you do one step after another from the beginning to the end. The flow proceeds in a straight line with no detours. However, the recipe is too simple because it does not include conditions that must be met before moving to later steps.
Figure 1.2 is a flowchart, and it shows what is happening in the first step. The rectangles are things to do, and the diamond is a decision to be made that includes a condition.
You may find it useful to use such a chart to map out the flow of your code.
These instructions are better. We test several conditions to determine the next course of action. We still are not checking whether a condition is met after repeating a step multiple times.