Week 2: Conditionals and While Loops

222 words
1 min read
Python Week 1: the first filter for runtime behavior
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

Open gallery

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, else are mutually exclusive only when arranged correctly.
  • and, or, and not work on Boolean logic and truthiness.
  • String indexing starts at 0; negative indexing counts from the end.
  • while loops need a state update or they may never stop.

2. Common traps

  • Indentation changes meaning.
  • while conditions 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:
  1. What condition decides the branch?
  2. What state changes after each iteration?
  3. 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

Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.