Class 24 Quiz Flashcards
In a for … in loop, where does the loop variable get its values?
from the list of values following the keyword in
In a simple for loop, where does the loop variable get its values?
from the command line arguments
Should the loop variable in a for loop have a $ in front of it?
no
In a three statement for loop, what does the first statement do?
sets the initial value of a loop variable
In a three statement for loop, what does the second statement do?
it’s a logical expression and the loop will continue as long as its value is true
In a three statement for loop, what does the third statement do?
changes the value of the loop variable after each pass through the loop
Why are the three statements in a three statement for loop surrounded by two parentheses?
so the values of all variables will be treated as numbers
When does a while loop stop running?
when the command following while returns an exit status that is not 0
What does the continue command in a loop do?
stops that pass through the loop and returns to the top of the loop
What does the break command in a loop do?
jumps completely out of the loop