Module 2: Lesson 4


Python Flow Control

This lesson introduces Python commands that control how the computer executes a program. These commands include conditional statements, which control, based on a pre-defined condition, what code blocks are executed, and looping statements, which repeat code blocks until a predefined condition is met.

Objectives

By the end of this lesson, you will be learn about

  • write effective if statements to perform conditional code evaluation,
  • write for statements to iteratively process data, and
  • write while statements to perform a predefined operation until a condition is reached.

Time Estimate

Approximately 2 hours.

Activities

Video: Watch the Python flow control video, which will discuss how to use flow control statements like conditional statements and loops to write more effective and powerful Python program.

Notebook: Read and complete the practice exercises in the Python flow control notebook.


© 2017: Robert J. Brunner at the University of Illinois.

This notebook is released under the Creative Commons license CC BY-NC-SA 4.0. Any reproduction, adaptation, distribution, dissemination or making available of this notebook for commercial use is not allowed unless authorized in writing by the copyright holder.