Signed up recently but had issues with the confirmation email?
Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.
Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.
Programming constructs: sequence, iteration, branching.
2.2.1 Programming Techniques
Practise exam questionsProgramming Techniques — Note 1 of 6
Candidates need to understand the constructs of sequence, iteration and branching, and use them independently and in combination to produce a solution. This includes IF (with ELSEIF and ELSE) and select case statements, and both condition-controlled (e.g. while, repeat until) and count-controlled (e.g. FOR) iteration. Candidates need to be able to read, create and trace code (for example using a trace table) that uses these constructs.
All programs are built from three constructs: sequence, iteration and branching (selection). You need to use them independently and in combination, and read, create and trace code that uses them.
while loop checks its condition BEFORE each iteration (it may run zero times); a do ... until loop checks AFTER (it always runs at least once).total = 0
for i = 1 to 5
mark = int(input("Enter mark: "))
if mark >= 0 AND mark <= 100 then
total = total + mark
else
print("Invalid mark")
endif
next i
do
answer = input("Continue? (y/n) ")
until answer == "y" OR answer == "n"
switch answer:
case "y":
print("Continuing")
default:
print("Goodbye")
endswitchInstructions executed one after another in order.
Choosing which code to run based on a condition, using if ... then ... elseif ... else ... endif or switch/case. The chosen branch runs once; code that repeats is iteration, not branching.
Repeating code. Count-controlled loops (for) repeat a set number of times; condition-controlled loops (while, do ... until) repeat until a condition changes.
return that always runs inside a loop ends the function on the first pass: put it after the loop, or inside an if to stop early, e.g. once an item is found.Past exam questions
Ready to test yourself?
Practise 2.2.1 questions