Iteration (Edexcel GCSE Computer Science): Flashcards
📚Flashcards
Practise the cards
13 cards from this deck
ShowHide
Practise the cards
13 cards from this deck
What is iteration?
What is iteration?
Repeating the same set of actions multiple times to automate repetitive tasks
Key characteristic of iteration
Key characteristic of iteration
You know in advance how many times to repeat
Most common way to create iteration in Python
Most common way to create iteration in Python
for loops
Purpose of 'for' keyword in Python
Purpose of 'for' keyword in Python
Starts the loop
Purpose of 'in' keyword in for loops
Purpose of 'in' keyword in for loops
Connects loop variable to data structure
Why is indentation crucial in Python loops?
Why is indentation crucial in Python loops?
Tells computer which commands belong inside the loop
What does range() function do?
What does range() function do?
Generates a sequence of numbers
Three parameters of range() function
Three parameters of range() function
Start, stop, step
Does range() include the stop number?
Does range() include the stop number?
No, it stops before the stop number
What does range(5) generate?
What does range(5) generate?
0, 1, 2, 3, 4
What must every for loop line end with?
What must every for loop line end with?
A colon
for...in loops work with:
for...in loops work with:
Values directly from data structure
for...in range() loops use:
for...in range() loops use:
Index positions and counting
