Your program consists of a set of statements. How the statements run depends on the programming constructs you use. The statements can run from top to bottom, but the program also can not run specific statements based on conditions you add to the code. When you add conditions to your code, the code is said to have multiple paths or branches.

In this module, you'll learn how to construct conditional logic to create multiple execution paths through your code. You'll learn how to use multiple paths in your code, and why. You'll also be introduced to looping constructs you can use to repeat statements. Finally, you'll have a look at pattern matching, a powerful feature that makes it possible to be expressive and clear, and to take on a more functional approach.

Learning objectives

In this module, you will:

  • Use if...elif...else to add conditional logic to your code.
  • Create repeat statements by using various loop constructs.
  • Understand the difference between various loop constructs and when to use them.