Lesson 9 Flashcards

1
Q

For loops

A

allow us to repeat code multiple times. It makes programs easier and simpler to read. You must have 4 spaces in front of the code that is part of the loop so that python recognizes that they are the same code

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

i

A

The traditional name for a counter variable. It will represent the current value of the loop.

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

in is a keyword

A

It shows that you are about to specify how many times the loop should repeat.

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

range()function

A

tells the loop to stop before the number listed in the range function. range(3) it goes from 0-2. It counts where a counter variable starts, ends, and the increment it goes up by. (4,13,4) It will count from 4 to 13 by increments of 4.

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

for i in range(3):

A

an example of a for loop.

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

Indented code

A

indicates the code is part of a loop listed before. Don’t indent if you want to start code outside of the loop

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

While loops

A

repeats as long as the conditional statement is true. l It replaces the counting portion with a conditional statement. Keyword is “while.”

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

Nested loop

A

a loop in another loop.

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

While loop formula

A

while Booleanexpression :

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