Iteration Flashcards
1
Q
What is iteration?
A
The process of code being repeated until a specific end result is achieved.
2
Q
Why do we use iteration?
A
It allows variation and repetition
3
Q
What is a counter controlled loop and what do we use?
A
Loops that execute for a fixed number of times
(For)
4
Q
Example
For in the range (,,):
A
Example :)
Stops 1 before stop
5
Q
What is a condition controlled loop?
And which one?
A
Dont know beforehand how many repetitions are required
Stops when a certain condition comes true
While
6
Q
What does break do?
What does continue do?
What does pass do?
A
- exits immediately from loop
I.e i = 0
While true:
i+=1
Print(i)
If i == 10:
Break
- Immediately starts next iteration
- Null, do nothing