Appendix AFlowcharts
Flowcharts allow us to visualize how the application will flow from one instruction to the next, from start to finish. Building a flowchart before we start to code a program helps ensure that we don't skip any steps in the program and gives us a tool to easily communicate those steps to others.
FLOWCHART BASICS
One of the interesting things about programming is how surprisingly simplistic computers and programs really are. Even though we can create massive-scale programs that perform complex tasks, there are really only three things a program can do:
- Sequence: Execute a series of statements in order
- Branch: Follow a specific path based on a defined condition
- Loop: Repeat a series of instructions until a condition is met
We use the term flow of control to define the path that a program takes from one instruction to the next, and we use a flowchart to visualize the flow of control. Another important term is algorithm. While TV shows and movies make algorithms sound like very technical things that only a software developer could understand, an algorithm is really just a well-defined set of instructions that a computer or similar machine can follow to reach a desired output. In other words, we use flowcharts to diagram algorithms.
Sequences
By default, the simplest path in an algorithm is to move sequentially from one statement to the next. For example, in the following pseudocode, we have two statements:
greeting = "Hello, world!"
print(greeting)
The ...
Get Job Ready Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.