Phase 1: Programming Fundamentals I · ~35 minutes · Python · uv
Control Flow — Conditionals
Python physically will not let you write if x = 5: — and that refusal is a safety feature, not an inconvenience.
Hiring signal: Distinguishes = from == on sight and correctly reasons about truthy/falsy edge cases instead of guessing
What you will learn
- Write if/elif/else chains that branch correctly, including boundary values
- Explain the difference between = (assignment) and == (comparison), and why confusing them is a real error class
- List Python's falsy values and explain why they're falsy
- Predict whether a truthy/falsy edge case executes a given branch
Introduction
Type: Learn Languages: Python Prerequisites: Lesson 01 (Variables, Types, and the Assignment Trap) Time: ~35 minutes
Objective
Learning objectives
- Write
if/elif/else chains that branch correctly, including at boundary values - Explain the difference between
= (assignment) and == (comparison), and why confusing them is a real, common error class - List Python's falsy values and explain why they're falsy
- Predict whether a truthy/falsy edge case executes a given branch
What you're building
A script (grade_calculator.py) that:
- Defines a
grade_band(score) function using the boundaries above (90/80/70/60), using >= correctly at every boundary - Tests it against at least six values, including at least two exact boundary values (like
90 and 80) and one just-below-boundary value (like 89.999) - A short written note (as a comment or a printed line) diagnosing what would happen if
>= were replaced with > at the 90 boundary specifically
A student writes if []: inside their program and is confused that the branch never runs, "even though [] is a real, valid list, not nothing." What's the accurate explanation?
"Falsy" is not the same claim as "invalid" or "doesn't exist." [] is a completely real, valid Python list — you can call methods on it, pass it to functions, check its type. It is simply also one of the specific values Python treats as False when used directly as a condition, exactly like 0 is a real, valid number that's also falsy. This is consistent everywhere a value is used as a condition — if, while, and boolean operators like and/or all use the same truthy/falsy rules, not a special case for if alone.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers The Problem, Check Yourself, Key Terms & Next — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy