Chapter 8 Loop structures Flashcards
A Python while loop implements a definite loop.
False
A sentinel loop should not actually process the sentinel value.
True
What statement can be executed in the body of a loop to cause it to terminate?
Break
identify the loop: asks the user whether to continue on each iteration
Interactive
identify the loop: continues until a special value is input
Sentinel
identify the loop: tests the loop condition after executing the loop body
post-test
Briefly explain why the expression:
response[0] == “y” or “Y”
though a syntactically valid expression, always evaluates to True.
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.