Chapter 8 Loop structures Flashcards

1
Q

A Python while loop implements a definite loop.

A

False

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

A sentinel loop should not actually process the sentinel value.

A

True

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

What statement can be executed in the body of a loop to cause it to terminate?

A

Break

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

identify the loop: asks the user whether to continue on each iteration

A

Interactive

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

identify the loop: continues until a special value is input

A

Sentinel

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

identify the loop: tests the loop condition after executing the loop body

A

post-test

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

Briefly explain why the expression:

response[0] == “y” or “Y”

though a syntactically valid expression, always evaluates to True.

A

This will always evaluate as true because the statement after or ,”Y”, does not apply to the response[0] line it is just its own string. What this means is that it will allow any string that doesn’t begin with a lowercase “y” to be processed as True, because it is still a string.

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