Class 24 Quiz Flashcards

1
Q

In a for … in loop, where does the loop variable get its values?

A

from the list of values following the keyword in

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

In a simple for loop, where does the loop variable get its values?

A

from the command line arguments

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

Should the loop variable in a for loop have a $ in front of it?

A

no

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

In a three statement for loop, what does the first statement do?

A

sets the initial value of a loop variable

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

In a three statement for loop, what does the second statement do?

A

it’s a logical expression and the loop will continue as long as its value is true

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

In a three statement for loop, what does the third statement do?

A

changes the value of the loop variable after each pass through the loop

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

Why are the three statements in a three statement for loop surrounded by two parentheses?

A

so the values of all variables will be treated as numbers

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

When does a while loop stop running?

A

when the command following while returns an exit status that is not 0

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

What does the continue command in a loop do?

A

stops that pass through the loop and returns to the top of the loop

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

What does the break command in a loop do?

A

jumps completely out of the loop

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