Pickles AcademyStart for free

What does the program print? (Python) – practice for Years 7–9

Sample questions on What does the program print? (Python) with the right answer and a worked solution, from easy to hard. In the Pickles Academy app a child gets new questions of the same kind every time, so they can't just learn the answers by heart.

Subject
Computing
Year
Years 7–9
Curriculum area
Algorithms and programming

Question types: What does it print?

Rule: What does the program print? (Python)

Run the program line by line and write down the variables. x = x + 3 means: add 3 to x.

range(1, 5) gives 1, 2, 3, 4 but not 5. // is whole-number division, % the remainder.

Example: s = 0, then for i in range(1, 4): s = s + i → 1 + 2 + 3, it prints 6

Watch out: range(1, 5) never reaches 5: the loop runs 4 times, not 5.

Sample questions

  1. Question 1 Easy

    What does this program print?

    Show the solution
    Answer: 32

    How it works: Values of b: 8 → 32. The program prints 32.

  2. Question 2 Normal

    What does this program print?

    Show the solution
    Answer: 27

    How it works: Values of p: 1 → 3 → 9 → 27. The program prints 27.

  3. Question 3 Hard

    What does this program print?

    Show the solution
    Answer: 16

    How it works: Values of s: 0 → −1 → 1 → 0 → 4 → 3 → 9 → 8 → 16. The program prints 16.

All Computing topics

Keep practising in the app

In a minute, your child has their own avatar and a first task. Free, no ads, data in the EU.

Start for free