Week 2: Conditionals and While Loops
222 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Week 2: Conditionals and While Loops > **Course:** Jan 2026 - Python > **Focus:** Decisions, state, and loops that keep running until a condition breaks. --- ## 1.

Visual strip
Relevant recall pieces for this note
Week 2: Conditionals and While Loops
Course: Jan 2026 - Python Focus: Decisions, state, and loops that keep running until a condition breaks.
1. Core idea
Week 2 is about control flow: choose a branch, or keep looping until state changes.
What to remember
if,elif,elseare mutually exclusive only when arranged correctly.and,or, andnotwork on Boolean logic and truthiness.- String indexing starts at
0; negative indexing counts from the end. whileloops need a state update or they may never stop.
2. Common traps
- Indentation changes meaning.
whileconditions should be checked before every iteration.- Off-by-one bugs usually come from the loop boundary, not the arithmetic.
- A loop variable can be a state flag, not just a counter.
3. Speedrun pattern
When you see a Week 2 question, ask:
- What condition decides the branch?
- What state changes after each iteration?
- Is the answer about one pass, many passes, or no pass at all?
4. Micro revision
- Comparison:
==,!=,>,<,>=,<= - Boolean operators:
and,or,not - Loop state: counter, flag, sentinel
Assignment anchor
Navigation
- Previous: Week 1 Notes
- Next: Week 3 Notes