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 progressRepeating Actions
Iteration means repetition. Imagine writing "I will not be late" 100 times - boring! A loop does it for you. FOR loops repeat a set number of times (write it 100 times). WHILE loops repeat while a condition is true (keep writing until the teacher says stop). An UNTIL loop (REPEAT UNTIL on AQA, DO UNTIL on OCR) always runs at least once before checking. Loops are the power tools of programming!
FOR repeats a counted number of times. WHILE tests before the body, so it runs zero or more times. UNTIL tests after the body, so it runs at least once. The loop that tests at the end is REPEAT UNTIL on AQA and DO UNTIL on OCR. Here are the three loops in OCR style. The UNTIL loop adds an input line so that answer can change.
for i = 1 to 5
print(i)
next i
score = 0
while score < 10
score = score + 1
endwhile
do
print("try again")
answer = input("Again?")
until answer == "yes"
AQA style: FOR i ← 1 TO 5 ... ENDFOR, WHILE ... ENDWHILE and REPEAT ... UNTIL .... Edexcel does not set a strict pseudocode style.
Make this stick
Signing in gives access to all PrepWise features.