Download CD Content
So far, the programs you've written have had a simple, sequential flow: each statement is executed once, in order, every time. If you were limited to just this type of programming, it would be very difficult, if not impossible, to write complex applications. But in this chapter, you learn how to selectively execute certain portions of your code and repeat parts of your program. Specifically, you learn to do the following:
Generate random numbers using randrange()
Use if structures to execute code based on a condition
Use if-else structures to make a choice based on a condition
Use if-else-elif structures to make a choice based on several conditions
Use while loops to repeat parts of your program
Plan your programs using pseudocode