Repetition (Edexcel GCSE Computer Science): Flashcards
📚Flashcards
Practise the cards
13 cards from this deck
ShowHide
Practise the cards
13 cards from this deck
Repetition in programming
Repetition in programming
Running the same code multiple times
Two main types of repetition
Two main types of repetition
Condition-controlled and count-controlled
Condition-controlled repetition
Condition-controlled repetition
Code repeats while a condition remains true
Count-controlled repetition
Count-controlled repetition
Code repeats for a specific, fixed number of times
While loop behavior
While loop behavior
Executes as long as the specified condition is true
Basic while loop syntax in Python
Basic while loop syntax in Python
while <condition>: <command>
For loop purpose
For loop purpose
Repeats code for a known, specific number of times
Basic for loop syntax in Python
Basic for loop syntax in Python
for <id> in range(<start>, <stop>, <step>): <command>
range() function purpose
range() function purpose
Generates a sequence of numbers for loops
range(0, 10) output behavior
range(0, 10) output behavior
Gives numbers 0-9, stops before 10
When to use while loops
When to use while loops
When you don't know how many times to repeat
When to use for loops
When to use for loops
When you know exactly how many repetitions needed
Boolean operators for compound conditions
Boolean operators for compound conditions
and, or, not
