Printable worksheet ยท 4 of 4

A range has a precise stopping point - Paper 4

Read the information, then answer the questions. An adult may read the instructions aloud. Show your working where asked.

Read before answering

Python paper trace: for n in range(-1, 3): print(n). The start is included and stop excluded; the default step is +1. Printing occurs once for each supplied n. Also consider range(3, -1), still using +1. Record values and iteration counts separately before using an approved interpreter.

Worksheet preview

  1. List the values printed by range(-1, 3) and count them.
  2. If the stop changes from 3 to 4, what extra value is printed?
  3. How many iterations does range(3, -1) produce with default step +1?

This exercise is included in the free preview. Register free to complete it and download the preview PDFs. No payment is required.

Register free

Already registered? Sign in