1.6.2
Iteration
Iteration
Iteration
Iteration allows a group of statements to be repeated multiple times. Iteration statements are often called loops.
![Illustrative background for Indefinite iteration](https://image-v2.cdn.app.senecalearning.com/2018-08/74d82980-f764-423c-a8bb-3382813f616d/Indefinite%20Iteration,h_400,q_80,w_640.png)
![Illustrative background for Indefinite iteration ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-08/74d82980-f764-423c-a8bb-3382813f616d/Indefinite%20Iteration,h_400,q_80,w_640.png)
Indefinite iteration
Indefinite iteration
- A block of code will repeat whilst a specified condition is true.
- For example: the while loop will continue to execute an indented code block while a certain condition is true.
![Illustrative background for Definite iteration](https://image-v2.cdn.app.senecalearning.com/2018-08/f7192a21-19f2-464e-9abb-c6f34f11ab24/Definite%20Iteration,h_400,q_80,w_640.png)
![Illustrative background for Definite iteration ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-08/f7192a21-19f2-464e-9abb-c6f34f11ab24/Definite%20Iteration,h_400,q_80,w_640.png)
Definite iteration
Definite iteration
- A block of code will repeat a known number of times.
- For example: a for loop will execute an indented block for each value in a list of values.
![Illustrative background for Flow diagram](https://image-v2.cdn.app.senecalearning.com/2018-08/05478307-2c1a-477d-a959-b7d2b44b220a/2.2.3%20Iteration,h_400,q_80,w_640.png)
![Illustrative background for Flow diagram ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-08/05478307-2c1a-477d-a959-b7d2b44b220a/2.2.3%20Iteration,h_400,q_80,w_640.png)
Flow diagram
Flow diagram
- A flow diagram for iteration uses the diamond shape.
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Jump to other topics
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
![Go student ad image](/en-GB/revision-notes/_next/image?url=%2Fen-GB%2Frevision-notes%2Fimages%2Fgo-student-uk-ad.jpg&w=640&q=100)
Unlock your full potential with GoStudent tutoring
Affordable 1:1 tutoring from the comfort of your home
Tutors are matched to your specific learning needs
30+ school subjects covered