ProgrammingStudy Notes

Practical Examples (OCR Pseudocode & Python)

Part of Iteration (Loops)GCSE Computer Science

This study notes covers Practical Examples (OCR Pseudocode & Python) within Iteration (Loops) for GCSE Computer Science. Revise Iteration (Loops) in Programming for GCSE Computer Science with 15 exam-style questions and 8 flashcards. This is a high-frequency topic, so it is worth revising until the explanation feels precise and repeatable. It is section 5 of 7 in this topic. Use this study notes to connect the idea to the wider topic before moving on to questions and flashcards.

Topic position

Section 5 of 7

Practice

15 questions

Recall

8 flashcards

Practical Examples (OCR Pseudocode & Python)

Example 1: Sum Numbers 1 to 100

OCR Pseudocode:

total = 0
for i = 1 to 100
    total = total + i
next i
print("Sum: " + total)
// Output: Sum: 5050

Python Equivalent:

total = 0
for i in range(1, 101):
    total = total + i
print("Sum:", total)
# Output: Sum: 5050

Example 2: Guessing Game

secretNumber = 42
guess = 0
attempts = 0

while guess != secretNumber
    guess = input("Guess the number: ")
    attempts = attempts + 1
    if guess < secretNumber then
        print("Too low!")
    elseif guess > secretNumber then
        print("Too high!")
    endif
endwhile

print("Correct! You took " + attempts + " attempts")

Example 3: Input Validation with DO-WHILE

do
    age = input("Enter your age (0-120): ")
until age >= 0 AND age <= 120
print("Valid age entered: " + age)

Keep building this topic

Read this section alongside the surrounding pages in Iteration (Loops). That gives you the full topic sequence instead of a single isolated revision point.

Practice Questions for Iteration (Loops)

Which type of loop is best used when you know exactly how many times the loop should repeat?

  • A. WHILE loop
  • B. FOR loop
  • C. REPEAT-UNTIL loop
  • D. IF statement
1 markfoundation

Explain what an infinite loop is, state one cause of an infinite loop, and describe one consequence of running an infinite loop in a program.

3 marksstandard

Quick Recall Flashcards

What is iteration?
Repeating a set of instructions
When use a FOR loop?
When you know how many times to repeat

Want to test your knowledge?

PrepWise has 15 exam-style questions and 8 flashcards for Iteration (Loops) — with adaptive difficulty and instant feedback.

Join Alpha