Section 2

Decisions and loops

Programs that choose and repeat. True and False and the comparisons that produce them, if, elif and else, while loops, for loops with range, and break and continue. You will learn to trace a program by hand and hunt bugs, then build a number-guessing game against a computer that picks its secret number.

  • 7 lessons
  • 1 h 51 min

0 of 7 lessons complete

Lessons

  1. 1

    True, False and comparisons

    Lesson · 12 min

  2. 2

    Making decisions: if, elif and else

    Lesson · 15 min

  3. 3

    Repeating with while

    Lesson · 15 min

  4. 4

    Counting loops: for and range

    Lesson · 15 min

  5. 5

    Leaving early: break and continue

    Lesson · 14 min

  6. 6

    Tracing and debugging

    Lesson · 15 min

  7. 7

    Lab: a number-guessing game + section quiz

    Lab · 25 min