Practical Examples (GCSE Pseudocode & Python)

Test yourself on Iteration (Loops) with exam style questions, marked instantly.

Flashcards that come back just before you would forget them.

A revision plan that remembers what you know and shows what to do next.

See which topics you have nailed and which need another look.

Quiz yourself on Iteration (Loops)Get your flashcardsBuild my revision planTrack my progress

Practical Examples (GCSE Pseudocode & Python)

Example 1: Sum Numbers 1 to 100

GCSE Pseudocode:

total = 0
for i = 1 to 100
    total = total + i
next i
OUTPUT "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
    INPUT guess
    attempts = attempts + 1
    if guess < secretNumber then
        OUTPUT "Too low!"
    elseif guess > secretNumber then
        OUTPUT "Too high!"
    endif
endwhile

OUTPUT "Correct! You took " + attempts + " attempts"

Example 3: Input Validation with DO UNTIL (OCR style)

do
    INPUT age
until age >= 0 AND age <= 120
OUTPUT "Valid age entered: " + age

Make this stick

Signing in gives access to all PrepWise features.

PrepWise is a trading name of A3M Quality Solutions Limited, registered in England and Wales, company number 14959172. Registered office: 202 Stroud Road, Gloucester, GL1 5LA. ICO registration ZC267069.