if and else

6 min · 10 quiz questions

Year 8 · Chapter 9 Python decisions and loops · Lesson 1. This lesson goes with level 8 of the Byte Lab Year 8 game. Play the level first, then use this page to revise.

Learning objectives. By the end of this lesson you should be able to write a condition with a comparison operator; use if, else and elif in Python with the right colons and indentation; turn input into a number with int(); combine conditions with and, or and not; and test a program with edge values.

In this lesson

  • Selection: making decisions
  • Comparison operators
  • if and else
  • elif: more than two choices
  • input() gives text
  • and, or, not
  • Testing with edge values
  • Common errors
  • Shortcuts to know
  • Real mission: your ticket machine
  • Revision checklist