Python Lect 2
Python Lect 2
Cont…
ITC
CBS
While Loop (Indefinite Loop)
• Flow of Execution:
• Looking at the for loop, for and in are reserved Python keywords, and
friend and friends are variables.
Loop Patterns
• We call the while statement an indefinite loop because it simply loops
until some condition becomes False, whereas 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 we use a for or while loop to go through a list of items or the
contents of a file and we are looking for something such as the largest
or smallest value of the data we scan through.
Loop Patterns Cont…
• These loops are generally constructed by: