• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/7

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

7 Cards in this Set

  • Front
  • Back

while statement

Same as English meaning.


n = 5
while n > 0:
print n
n = n-1
print 'Blastoff!'


“While n
is greater than 0, display the value of n and then reduce the value of n by 1. When
you 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, possibly
changing 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.