Skip to content
CCC Python Course

Booleans and conditionals

Stage
1
Module
M1.4
Lessons
1

In this module

  • Compare values with ==, !=, <, <=, >, >=, and test membership with in.
  • Branch a program's logic with if, elif and else.
  • Combine conditions with and, or and not, and chain comparisons like 0 <= x <= 10.
  • Write a short either/or value in one line with a conditional expression.

Before this module

Lessons

  1. 1Booleans and conditionals

Practice

Try these on the judges. Each link opens the problem on WMOJ or DMOJ.

  1. 2021 J1
    Boiling Water (opens on WMOJ in a new tab) WMOJ

    Turn a boiling point into an atmospheric pressure and a three-way elevation reading.

  2. 2023 J1
    Deliv-e-droid (opens on WMOJ in a new tab) WMOJ

    Score a delivery robot's run from its package count and its collisions, with a bonus condition.

  3. 2026 J1
    Concert Tickets (opens on WMOJ in a new tab) WMOJ

    Decide whether a concert-goer can buy their tickets from the remaining supply.

  4. 2017 J1
    Quadrant Selection (opens on DMOJ in a new tab) DMOJ

    Decide which quadrant a point falls in from the signs of its coordinates.

    Why DMOJ: Tries the same kind of decision on DMOJ, which holds 2014 to 2020.