term1 Definition1term2 Definition2term3 Definition3
Please sign in to your Google account to access your documents:
while statement
Same as English meaning.
n = 5while n > 0:print nn = n-1print 'Blastoff!'
“While nis greater than 0, display the value of n and then reduce the value of n by 1. Whenyou get to 0, exit the while statement and display the word Blastoff!”
loop
When the code looks back around to the to. Each time we execute the body of the loop, we call it an iteration.
iteration variable
The variable that changes each time the loop executes and controls when the loop finishes. Without the iteration variable you will have a infinite loop.
continue statement
You can use the continue statement to skip to the next iteration without finishing the body of the loop for the current iteration.
Returns back to top of loop.
while vs for
While statement is indefinite loop because it simply loops until some condition becomes False.
The for loop is looping through a known set of items so it runs through as many iterations as there are items in the set. Often used for list of things to loop through.
loops are generally constructed by:
• Initializing one or more variables before the loop starts.• Performing some computation on each item in the loop body, possiblychanging the variables in the body of the loop.• Looking at the resulting variables when the loop completes.
break statement
Used to jump out of a loop.
Need help typing ? See our FAQ (opens in new window)
Please sign in to create this set. We'll bring you back here when you are done.
Discard Changes Sign in
Please sign in to add to folders.
Sign in
Don't have an account? Sign Up »
You have created 2 folders. Please upgrade to Cram Premium to create hundreds of folders!