for loop: for i from 1 to n

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

for loop: for i from 1 to n

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Does a FOR loop repeat a block of instructions a fixed number of times?
A False
B True
2. Which keyword sets the starting value of the loop variable?
A FROM
B TO
3. Which keyword sets the ending value of the loop variable?
A TO
B FROM
4. Should a FOR loop be closed with END FOR?
A No
B Yes
5. Is ENDFOR written as one word in VCAA pseudocode?
A False
B True

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1FOR i FROM 1 TO 10 AThe closing keyword should be written as END FOR, not ENDFOR
2END FOR BFOR loop
3A structure that repeats instructions a fixed number of times CAssignment in pseudocode should use ←, not =
4The keyword that sets where the loop variable stops counting DStarts a loop counting i from 1 up to 10
5FOR i FROM 1 TO 10 DISPLAY i ENDFOR ECloses a FOR loop block
6FOR j FROM 1 TO 5 j = j + 1 END FOR FTO

Definitions

FOR i FROM 1 TO n

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
___ i FROM 1 TO 5
2.
FOR i ____ 1 TO 5
3.
FOR i FROM 1 __ 5
4.
FOR i FROM 1 TO 5 DISPLAY i _______
5.
___ count FROM 1 TO 10

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A FOR i TO 1 FROM 10
B DISPLAY i
C END FOR
Question 2
A FOR i FROM 1 TO 10
B PRINT i
C END FOR
Question 3
A FOR i FROM 1 TO 10
B DISPLAY i
C ENDFOR
Question 4
A FOR i FROM 1 TO n
B total <- total + i
C DISPLAY total
D END IF
Question 5
A FOR i FROM 1 TO 5
B DISPLAY i
C i <- i + 1
D END FOR
E NEXT i

Answer Key

for loop: for i from 1 to n
Section A: Quick Questions
Q1
B — True
Q2
A — FROM
Q3
A — TO
Q4
B — Yes
Q5
A — False
Section B: Match the Pairs
Q1
FOR i FROM 1 TO 10 → Starts a loop counting i from 1 up to 10
Q2
END FOR → Closes a FOR loop block
Q3
A structure that repeats instructions a fixed number of times → FOR loop
Q4
The keyword that sets where the loop variable stops counting → TO
Q5
FOR i FROM 1 TO 10 DISPLAY i ENDFOR → The closing keyword should be written as END FOR, not ENDFOR
Q6
FOR j FROM 1 TO 5 j = j + 1 END FOR → Assignment in pseudocode should use ←, not =
Section C: Definitions
Q1
FOR i FROM 1 TO n — A loop that repeats its instructions a fixed number of times, counting the variable i from 1 up to n
Section D: Fill in the Blanks
Q1
FOR i FROM 1 TO 5
Q2
FOR i FROM 1 TO 5
Q3
FOR i FROM 1 TO 5
Q4
FOR i FROM 1 TO 5 DISPLAY i END FOR
Q5
FOR count FROM 1 TO 10
Section E: Spot the Error
Q1
A — The keywords are in the wrong order — it should read FOR i FROM 1 TO 10.
Q2
B — VCAA pseudocode uses DISPLAY to output a value, not PRINT.
Q3
C — The closing keyword should be written as END FOR, not ENDFOR.
Q4
D — A FOR loop must be closed with END FOR, not END IF.
Q5
E — VCAA pseudocode closes a FOR loop with END FOR; NEXT i is not valid syntax.