Chapter 3: Branching, while Loops, and Program Planning: The Guess My Number Game


Download CD Content

Overview

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




Python Programming for the Absolute Beginner
Python Programming for the Absolute Beginner, 3rd Edition
ISBN: 1435455002
EAN: 2147483647
Year: 2003
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net