Knowledge organisersProgramming Fundamentals
Practical use of the techniques, Understanding of each technique
Iteration means repeating a set of instructions. There are two main types: count-controlled loops (FOR loops) that repeat a fixed number of times, and condition-controlled loops (WHILE and DO-UNTIL) that repeat until a condition changes. Loops can also be nested, meaning one loop inside another.
False. while team != "stop" is common.while hours != 0 is safer than while hours > 0 (user could enter -1 and bypass the check).for x in list: — x is the item VALUE, not an index. Do not then try to access list[x] as x is not an index number.# FOR loop (count-controlled)
for i in range(5):
print("Iteration", i)
# WHILE loop (condition-controlled)
password = ""
while password != "secret":
password = input("Enter password: ")
print("Access granted!")