B2.3 Programming constructsB2.3.3

Looping structures for repeated actions

Construct programs that utilize looping structures to perform repeated actions

SL + HL≈ 65 minCommand term: ConstructPremium

In this lesson

  • Writing count-controlled (for) and condition-controlled (while) loops in Java and Python
  • Choosing the right kind of loop for a task
  • Using counters, totals, flags, nested loops and break
  • Tracing loops and avoiding off-by-one errors and infinite loops

This lesson is part of Premium

Every topic has one free lesson. Premium unlocks every interactive lesson, the exam-style questions at the end of each one, and the rest of Praxis IB.

What's inside

  1. LearnRepeating actions
  2. CodeA times table
  3. CodeCounting with a for-each loop
  4. CodeA while loop that waits for the right answer
  5. LabLoop lab
  6. CheckQuick check
  7. CodeAsking until the input is valid
  8. CodeNested loops
  9. CodeLeaving a loop early
  10. CodeUsing a flag
  11. CodeA loop to trace
  12. CheckTrace the loop
  13. Checkfor or while?
  14. ExamWorked exam answer
  15. ReviewMistakes examiners see
  16. Exam practiceExam-style questions

Ends with 4 exam-style questions worth 13 marks, with a self-marking markscheme.