GRADE 9 · COMPUTING · UNIT 1 · LESSON 1.4

Computational thinking and programming

Loops in text-based programming

Read a little. Try the workbook. Check your answers. Choose one section below to get started.

14 fillable worksheet pagesRead at your own pace

LET’S LOOK, THINK AND TRY

Loops in text-based programming

I can…
  • Predict Python loop output for one-, two- and three-argument range
  • Write FOR loops with a chosen start and stop

Read the indentation and range

A Python for header ends with a colon. The indented body repeats, and the unindented instruction after it runs after the loop. range(stop) starts at 0. range(start, stop) uses the specified start. With a positive step, the stop value is excluded.

Trace a step before counting iterations

range(start, stop, step) supplies values separated by the stated nonzero step. Write the values until the next one would cross the excluded stop boundary. A negative step counts down, while a zero step is invalid. These explicit-step exercises extend the book examples. Distinguish a predicted paper trace from the result of actually running a program.

Original PaxaKids learning scene for Loops in text-based programming. The scene supplies context, not assessed measurements or counts.
An original PaxaKids scene for this topic. Use the stated values and exact workbook diagrams for computing work.

Work through an original example

Predict the values and total for a Python loop that starts total at 0 and adds each n in range(3, 10, 2).

Work through the reasoning

The supplied values are 3, 5, 7 and 9. The next value would be 11, beyond the stop boundary, so there are four iterations. The successive totals are 3, 8, 15 and 24. The final total is 24. The stop value 10 is not supplied.

Try it before the workbook

What values does range(4) supply?

Use the example to choose your first step. This short preparation question is separate from your workbook. Open the check clue when you are ready.

Explore the clues

Open one card at a time to review your thinking.

Remember the idea

A Python for header ends with a colon. The indented body repeats, and the unindented instruction after it runs after the loop. range(stop) starts at 0. range(start, stop) uses the specified start. With a positive step, the stop value is excluded.

Check your first try

0, 1, 2, 3

With one argument, the start is 0 and the default step is 1. The supplied values stop before 4.

Explain and check
  • Match exact code outputs, binary widths and stated units. Explain your method.
  • Check the question, rules, outputs and units. Explain why your method works.
Paxa the Fox

Think it through with Paxa!

Trace the stated rules and distinguish predictions from actual observations.

Original computing practice files

Optional small offline examples and fictional datasets, created for PaxaKids. They are supplementary practice, not publisher downloads or complete implementations of every workbook project. The page does not execute these files. Inspect code with a grown-up before using it in an approved offline environment; do not use real personal data.

Our Unit 1 learning path
  1. Lesson 1.1: Pseudocode
  2. Lesson 1.2: Iteration
  3. Lesson 1.3: Creating algorithms
  4. Lesson 1.4: Loops in text-based programming
  5. Lesson 1.5: Programming with data
  6. Lesson 1.6: Comparing algorithms
  7. Lesson 1.7: Searching algorithms
  8. Lesson 1.8: Testing
  9. Lesson 1.9: Physical computing
  10. Lesson 1.10: Word guess
  11. Lesson 1.11: Flowchart - Pseudocode - Program code
  12. Lesson 1.12: Original Paxa project: Revision challenge app
  13. Lesson 1.13: Check your progress
  14. Lesson 1.14: Computational thinking and programming - unit check
For grown-ups: using this lesson

Discuss the idea and worked example, then try the workbook. Your answers are checked in your browser. Open responses need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses. Accept a sound alternative method.

Opening or checking a worksheet does not complete a lesson. Choose “Mark lesson finished” when ready. Optional account progress saves the selected grade, lesson position and completion across devices. Personal worksheet responses stay in this tab; save your own copy before leaving.

2. Fill in your workbook

Use the original diagrams and stated conventions. Choose, write or draw on the pages, or use the larger Answer List controls. Code examples here are for tracing; this page does not execute them or connect to hardware. Use fictional data and approved supervised tools for project work.

Loops in text-based programming14 student pages · original artwork

Opening your PDF…

Swipe sideways across the worksheet on a small screen, or use “Answer list” for larger controls.

TAKE YOUR PRACTICE OFFLINE

3. Download the student worksheet

All 14 original A4 student pages, ready for pencil-and-paper practice. Choose Review Answers to check your work on this webpage.

Student worksheet only · PDF · 6.8 MiB · No answer key included

Download worksheet PDF ↓

TRY FIRST, THEN CHECK TOGETHER

Download the student worksheet →

4. Answers & guidance

Finished your try? Open the guide and compare one worksheet at a time. Your own words may be different and still explain the right idea.

Shown on this webpage only. There is no answer-key download, and this guide is left out when printing the page.

Show answers for all 14 worksheets

Worksheet 1

  1. Question 1: What determines the repeated block in Python? Its indentation under the loop header

Worksheet 2

  1. Question 2: How many times does print(turn) run? 4
  2. Question 3: What is the final number printed? 3
  3. Question 4: How often is Done printed? Once, after the loop

Worksheet 3

  1. Question 5: range(5): number of values 5
  2. Question 6: range(2, 6): number of values 4
  3. Question 7: range(2, 9, 3): number of values 3
  4. Question 8: Which expression supplies 1 through 8 inclusive? range(1, 9)

Worksheet 4

  1. Question 9: range(1, 10, 2): last value 9
  2. Question 10: range(8, 1, -2): last value 2
  3. Question 11: range(6, 0, -1): last value 1
  4. Question 12: range(5, 2): number of values 0
  5. Question 13: Which range is invalid because of its step? range(1, 5, 0)

Worksheet 5

  1. Question 14: How many output lines are produced? 8
  2. Question 15: What square is printed when number is 6? 36
  3. Question 16: What is the final square printed? 64
  4. Question 17: What goes wrong if the stop is changed from 9 to 8? The square of 8 is omitted

Worksheet 6

  1. Question 18: After number = 3: total 3
  2. Question 19: After number = 4: total 7
  3. Question 20: After number = 8: total 33
  4. Question 21: After number = 9: total 42

Worksheet 7

  1. Question 22: What belongs in the observed-result record? What the exact program actually produced, or Pending

Worksheet 8

  1. Question 23: How many times is the if condition tested? 6
  2. Question 24: How many readings satisfy the condition? 4
  3. Question 25: What changes if >= 0 becomes > 0? The two zero readings are no longer counted

Worksheet 9

  1. Question 26: What number does the faulty program display? 9
  2. Question 27: Which change fixes the accumulator fault? Remove total = 0 from inside the loop
  3. Question 28: Why is this a logic error? The program runs but calculates the wrong required result

Worksheet 10

  1. Question 29: What number does the faulty program display? 33
  2. Question 30: Which number is missing from the addition? 9
  3. Question 31: Which header meets the specification? for number in range(3, 10):

Worksheet 11

  1. Question 32: Inputs 3, 9: numeric result 42
  2. Question 33: Inputs 5, 5: numeric result 5
  3. Question 34: Inputs -2, 1: numeric result -2
  4. Question 35: For start 9 and end 3, which action is required? Show the range message and skip the summation

Worksheet 12

  1. Question 36: Which change can correct a missing-colon syntax error? Add : at the end of the loop header
  2. Question 37: Which evidence should accompany a correction? The input, expected result, observed result and retest

Worksheet 13

  1. Question 38: Write both programs with clear indentation and exclusive stop values. Add a compact prediction: first and last square lines, number of square lines and final accumulated sum. Run them if possible; label actual results or Pending separately. Squares: for number in range(1, 9): with indented print(number, number * number). Predict first line 1 1, last line 8 64, eight lines. Sum: total = 0 before for number in range(3, 10):; indented total = total + number; unindented print(total). Predicted final sum42. Accept equivalent correct Python loops with specified bounds, rather than a hard-coded answer or only built-in sum. Paper trace supports understanding; actual execution requires observed output. If no device, mark actual observation Pending. Check the student distinguishes printed output from variable state and keeps initialisation outside the loop. Grown-up review; discuss your evidence and reasoning.

Worksheet 14

  1. Question 39: Explain the endpoint correction and why initialisation belongs before the loop. Give expected results for (3, 9), (5, 5) and (9, 3), including the helpful error. State one limitation involving text input. Add an actual retest record or Pending and a reasoned paper trace. Correct header to for number in range(start, end + 1):, preserving the pre-loop total = 0 and the stated start>end rejection. Expected3..9=42;5..5=5 (one iteration);9..3 prints Start must not exceed end and skips calculation. Explain exclusive stop, one-time initialisation and rejected reversed interval rather than silently changing the request. int(input()) can raise ValueError for non-numeric text; current example assumes valid integer text and needs separate conversion handling for that case. Actual retest evidence must identify input, expected, observed, correction and outcome; otherwise Pending with paper trace. Sampled tests do not establish every input correct. Grown-up review; discuss your evidence and reasoning.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore Loops in text-based programming with this free Grade 9 Computing lesson. Read one idea together, try the fillable workbook and return to review at your own pace. Download the same student worksheet PDF for pencil-and-paper practice.

Fit learning around your family’s day. There is no timer and no sign-up is needed to use the lesson. An optional account saves your lesson position and completion across devices. Workbook responses and drawings stay in this tab; save a copy of your responses before leaving.

Understand your results

Closed answers are checked in your browser. Drawings and written explanations need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.

Choose Review Answers after trying the activity. The guide stays on the webpage; the worksheet download contains only the student pages.

For programme background, visit the Cambridge Lower Secondary Computing overview. PaxaKids provides independent original companion practice.

The original practice follows the source topic teaching.

The page references identify the reviewed actual supplied book teaching and related practice. Only the cited Learner’s Book teaching pages are listed here. No matching publisher Workbook 9 was supplied or cited. The original PaxaKids workbook is the student download; no textbook scan is published. Explanations, worked models and student workbooks here are original PaxaKids companion material.

The source topic number is preserved.