Control Structures in Python

Control Structures in Python#

According to Busbee and Braunschweig’s “Structured ProgrammingProgramming Fundamentals, “One of the most important concepts of programming is the ability to control a program so that different lines of code are executed or that some lines of code are executed many times. The mechanisms that allow us to control the flow of execution are called control structures. Flowcharting is a method of documenting (charting) the flow (or paths) that a program would execute. There are three main categories of control structures:”

  • Sequence [executes in given sequence]

  • Selection [selects between two or more flows using condition or question]

  • Iteration [repeats same piece of code multiple times]

This chapter provides an introduction to control structures in the Python programming langauge. Topics covered include:

  • Control flow and control structures

  • Event-controlled and count-controlled loops

  • Looping structures in Python (for and while)

Acknowledgements#

When building this chapter, the author consulted materials developed by:

Definitions and explanations in this lab are adapted from Kenneth Leroy Busbee and Dave Braunschweig, Programming Fundamentals: A Modular Structured Approach, 2nd Edition (Rebus Press, 2018)

Application#

Your answers to this chapter’s application questions should be added to the notebook template.

Submit the Colab link on Canvas for the assignment submission.

Chapter Contents#