Skip to main content

Week 3 syllabus map

  • L3.1: Introduction
  • L3.2: Introduction to while loop
  • L3.3: while to compute factorial
  • L3.4: Tutorial on while loop
  • L3.5: Introduction to for loop
  • L3.6: for loop to add the first n numbers
  • L3.7: for loop for multiplication tables
  • L3.8: More on range and for loop without range
  • L3.9: Formatted printing
  • L3.10: Tutorial on for loop and difference between while loop and for loop
  • L3.11: Nested for loop
  • L3.12: Tutorial on nested loops
  • L3.13: break, continue and pass
  • L3.14: Conclusion

Week 3 lecture pages

  1. L3.1: Introduction
  2. L3.2: Introduction to while loop
  3. L3.3: While to Compute Factorial
  4. L3.4: Tutorial on while loop
  5. L3.5: Introduction to for loop
  6. L3.6: for loop to add the first n numbers
  7. L3.7: for loop for multiplication tables
  8. L3.8: More on range and for loop without range
  9. L3.9: Formatted Printing
  10. L3.10: Tutorial on for loop and difference between while loop and for loop
  11. L3.11: Nested for loop
  12. L3.12: Tutorial on nested loops
  13. L3.13: break, continue and pass
  14. L3.14: Conclusion

30-minute pacing suggestion per lecture

  • 0-8 min: concept and syntax
  • 8-18 min: dry runs and step-by-step trace
  • 18-25 min: exam traps and error patterns
  • 25-30 min: quick practice + answer check

Week 3 exam traps (must master)

  • infinite while loop due to missing update
  • off-by-one boundaries in while and for
  • confusion between range(n), range(1, n), and range(1, n + 1)
  • confusing while and for use-cases
  • nested-loop indentation and variable shadowing mistakes
  • factorial base case (0! = 1)
  • misunderstanding break vs continue vs pass
  • using + for strings vs numbers in formatted printing
  • wrong alignment/width in f-strings (:>, :<, :^)

Final revision checklist

  • can trace loop variables manually
  • can predict output without running code
  • can convert simple while logic to for and vice versa
  • can write table output with clean formatting
  • can explain why a loop stops