← Back to the Introduction to Computer Science outline The Course Maker
← Introduction to Computer Science outline
Week 4 · Module overview

Week 4 — Booleans & Conditionals

Introduction to Computer Science Free sample edition

Welcome to your Week 4 Start Here page.

Why this matters

A pharmacy technician checking that a dose sits inside a safe range and a store clerk deciding whether a purchase earns free shipping both rely on yes-or-no tests asked in the right order.

In plain language

Until now, every program you wrote ran every line, top to bottom, every time, but this week your programs start making choices. You will ask yes-or-no questions with comparisons (tests such as "is 45 at least 300?") that Python answers with True or False. You will join questions together with the words and, or, and not (the joining words that build a bigger yes-or-no question). Then you will use if statements (instructions that run some lines only when a question comes out True) so a program can say "Keep going" on one run and "Goal met" on another. As always, you predict what each program prints and then run it to check.

  • Already covered: Week 2's bool values and Week 3's typed input.
  • This week: comparisons, and, or, not, truth tables, and if, elif, and else.
  • How they connect: every comparison gives a bool, and every if reads one.
  • Where we're going next: Week 5, Loops I: The while Loop.

Focus

How does a program choose which code runs?

By the end of this module, you should be able to:

  • [ ] predict whether a comparison gives True or False
  • [ ] work out a condition in the order not, then and, then or
  • [ ] predict which branch of an if, elif, and else chain runs

To-do

Plan your week

  1. Read Chapter 4 (about 40 minutes), then the lecture and slides.
  2. Work the lecture tutorial (60–90 minutes) and the practice set (about 20 minutes).
  3. Do the Coding Lab (about 90 minutes), the discussion, and the assignment.
  4. Take the quiz.

This week's checkpoint: predict which branch of a three-way chain runs, run it, and name the first test that came out True.

You've got this

Predict, then run, and ask your instructor if a step snags.

Built with The Course Maker · samples.thecoursemaker.com