Iteration Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is iteration?

A

The process of code being repeated until a specific end result is achieved.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why do we use iteration?

A

It allows variation and repetition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a counter controlled loop and what do we use?

A

Loops that execute for a fixed number of times
(For)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Example

For in the range (,,):

A

Example :)
Stops 1 before stop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly