Conditionals


Snakes on a computer

Intro

So far, the Python programs you’ve written have all run step by step, from top to bottom, executing each line exactly once. This week, and the next week, you’ll learn to write programs where the flow of control is more complex.

Programs can execute code based on some conditions, skip certain lines of code, or run code more than once. In these lessons, you’ll learn the Python tools to control the flow of the program.

Conditional statements will give you the power to write code that makes decisions. Loops will let you write code that goes back and repeats again.

Learning Outcomes

After this week, you will be able to:

  • Use comparison operators to check whether values are greater, less than, or equal
  • Use conditional statements to run different code in different situations

Welcome Video