List of Figures


Chapter 1: Getting Started: The Game over Program

Figure 1.1: The all-too familiar words from a computer game.
Figure 1.2: Your computer is soon to be home to Python.
Figure 1.3: Visit Python's home page to download the latest version of Python and read loads of information about the language.
Figure 1.4: Python in an interactive session, awaiting your command.
Figure 1.5: Your blank canvas awaits. Python is ready for you to write a program in script mode.
Figure 1.6: The results of running the Game Over program through IDLE.

Chapter 2: Types, Variables, and Simple I/O: The Useless Trivia Program

Figure 2.1: Whoa! Steve might think about a diet before he visits the sun.
Figure 2.2: Now I get it, the game is over.
Figure 2.3: Please, contain your applause.
Figure 2.4: The strings on the screen appear differently than in the program code.
Figure 2.5: With Python, you can add, subtract, multiply, divide, and keep track of a pregnant hippo's weight.
Figure 2.6: A shout-out to all the Larry's of the world.
Figure 2.7: Now, name is assigned a string based on whatever the user enters, including "Rupert".
Figure 2.8: This slightly low guess is printed several ways with the help of string methods.
Figure 2.9: The monthly total should be high, but not that high. Something is wrong.
Figure 2.10: Ah, 61,300 dollars a month is much more reasonable.

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

Figure 3.1: Got it in only three guesses! Try to beat that.
Figure 3.2: Ack! I got a total of 7 on my first roll, which means I lose.
Figure 3.3: Ha, you'll never crack the code.
Figure 3.4: Guess I should have picked a better password than "secret".
Figure 3.5: The correct password grants the user access, just like before.
Figure 3.6: Now, an incorrect password generates the stinging "Denied" message.
Figure 3.7: Looks like I was in a great mood while writing the Mood Computer program.
Figure 3.8: If you've ever been in charge of a three-year-old, this should bring back warm memories.
Figure 3.9: It seems you have an immortal hero. The only way to end the program was to stop the process.
Figure 3.10: Now, the program runs correctly, avoiding an infinite loop. Your hero's fate, however, is not as bright.
Figure 3.11: When you don't tip the maitre d', there are no tables to be found.
Figure 3.12: This time, my money has helped cure the maitre d' of his amnesia.
Figure 3.13: The number 5 is skipped with a continue statement and the loop ends through a break statement.
Figure 3.14: If you're not a member or a guest, you can't get in.
Figure 3.15: A guest can log in, but their security level is set quite low.
Figure 3.16: Looks like one of the guys logged in today.

Chapter 4: for Loops, Strings, and Tuples: The Word Jumble Game

Figure 4.1: The Word Jumble game. This jumble looks "difficult."
Figure 4.2: A for loop goes through a word the user enters, one character at a time.
Figure 4.3: The range() function and for loop allow you to count forwards, by fives, and backwards.
Figure 4.4: This program uses the len() function and the in operator to produce some information about your message.
Figure 4.5: You can directly access any character in a string through indexing.
Figure 4.6: You can access any letter of "index" with a positive or negative position number.
Figure 4.7: First, name gets the string "Chris", then it gets a different string, "Jackson". But no string values ever change.
Figure 4.8: Using a for loop, new strings are created. The program skips the concatenation operation for any vowels.
Figure 4.9: Fresh, hot slices of "pizza", made just the way you asked. The program also offers a "cheat sheet" so you can visualize how a slice will be created.
Figure 4.10: An example of slicing end point numbers for the string "pizza". You can use any combination of positive and negative end points for your slice.
Figure 4.11: At first, the hero has no items in his inventory. Then, the program creates a new tuple with string elements and our hero is stocked.
Figure 4.12: The hero's inventory is a tuple, which means it can be counted, indexed, sliced, and even concatenated with another tuple.
Figure 4.13: Each string is a single element in the tuple.
Figure 4.14: Slicing positions for tuples are defined between elements, just as they are for strings.

Chapter 5: Lists and Dictionaries: The Hangman Game

Figure 5.1: The "Hangman" game in action. Hmm . . . I wonder what the word could be.
Figure 5.2: I won this game!
Figure 5.3: This game ended badly, especially for the little guy made of text.
Figure 5.4: The hero's inventory is now represented by a list. The results look almost exactly the same as when the inventory was represented by a tuple in Hero's Inventory 2.0.
Figure 5.5: Since the hero's inventory is represented by a list, items can be added, modified, and deleted.
Figure 5.6: The user chooses from a menu to maintain the high scores list. Behind the scenes, list methods do the bulk of the work.
Figure 5.7: The new and improved version of High Scores stores a name with a score through nested sequences.
Figure 5.8: The variable language refers to a place in memory where the string value "Python" is stored.
Figure 5.9: The variables mike, mr_dawson, and honey all refer to the same list.
Figure 5.10: So "uninstalled" means fired. I was totally 404 on that.

Chapter 6: Functions: The Tic-Tac-Toe Game

Figure 6.1: The computer is full of ... confidence.
Figure 6.2: I did not see that coming. Even with simple programming techniques, the computer makes some pretty good moves.
Figure 6.3: I found the computer's weakness and won this time.
Figure 6.4: The instructions are displayed each time with just a single line of code— a call to a function I created.
Figure 6.5: Each function uses a parameter, a return value, or both to communicate with the main part of the program.
Figure 6.6: Functions can be called in different ways with the flexibility of keyword arguments and default parameter values.
Figure 6.7: This simple program has three different namespaces— one for each function, plus one for the global namespace.
Figure 6.8: You can read, shadow, or even change the value of a global variable from inside a function.
Figure 6.9: Each square number corresponds to a position in a list that represents the board.

Chapter 7: Files and Exceptions: The Trivia Challenge Game

Figure 7.1: The player is always presented with four inviting choices. But only one is correct.
Figure 7.2: The file is read using a few different techniques.
Figure 7.3: The same file is created twice, each time with a different file method.
Figure 7.4: Each list is written to and read from a file in its entirety.
Figure 7.5: Although the program can't convert "Hi!" to a number, it doesn't halt when exceptions are raised.

Chapter 8: Software Objects: The Critter Caretaker Program

Figure 8.1: You get to name your very own critter.
Figure 8.2: If you fail to feed or entertain your critter, it will have a mood change for the worse.
Figure 8.3: But with the proper care, your critter will come back to its original, sunny mood.
Figure 8.4: When the program invokes the Critter object's talk() method, the critter greets the world.
Figure 8.5: Two separate critters are created. Each says hi.
Figure 8.6: This time, each Critter object has an attribute name that it uses when it says hi.
Figure 8.7: Critters are being born left and right! The program keeps track of all of them through a single, class attribute, which it displays through a static method.
Figure 8.8: The object's private attribute and private method are indirectly accessed.
Figure 8.9: A property controls access to the Critter object's attribute for its name.

Chapter 9: Object-Oriented Programming: The Blackjack Game

Figure 9.1: One player wins, the other is not so lucky.
Figure 9.2: The battle description is the result of objects exchanging a message.
Figure 9.3: hero, a Player object, sends invader, an Alien object, a message.
Figure 9.4: Each Hand object is a collection of Card objects.
Figure 9.5: The Deck object inherits all of the methods of the Hand class.
Figure 9.6: By overriding the inherited __str__() method, objects of different derived classes are printed out differently.
Figure 9.7: Several functions and a class used in the program are from a programmer-created module.
Figure 9.8: Inheritance hierarchy of classes for the Blackjack game.

Chapter 10: GUI Development: The Mad Lib Program

Figure 10.1: A nicely laid-out GUI awaits the user's creativity.
Figure 10.2: The user has entered all of the necessary information.
Figure 10.3: After clicking the Click for story button, the text box displays the literary masterpiece.
Figure 10.4: You'll learn to create all of these GUI elements.
Figure 10.5: The program creates only a lone window. Hey, you have to start somewhere.
Figure 10.6: A GUI program can generate a console window too.
Figure 10.7: A label can provide information about a GUI.
Figure 10.8: You can click these lazy buttons all you want; they won't do a thing.
Figure 10.9: It's d j vu all over again. The program looks the same as its predecessor even though there are significant changes under the hood.
Figure 10.10: The button's event handler updates the number of times the button is clicked.
Figure 10.11: If the user fails to enter the correct password, the program politely refuses to divulge its secret.
Figure 10.12: Given the correct password, the program shares its invaluable knowledge to long life.
Figure 10.13: Each button is located in a unique cell, based on a row and a column number.
Figure 10.14: The results of the user's selections show up in the text box.
Figure 10.15: The user can select only a single movie type.

Chapter 11: Graphics: The Pizza Panic Game

Figure 11.1: The player must catch the falling pizzas.
Figure 11.2: Once a pizza gets by the player, the game is over.
Figure 11.3: My first graphics window. Not much, but it's mine.
Figure 11.4: By using the set_background() method, a background image can be applied to a Screen object.
Figure 11.5: You specify points on a graphics screen with x- and y-coordinate pairs.
Figure 11.6: The impressively high score is displayed after a Text object is instantiated.
Figure 11.7: Ah, the thrill of victory.
Figure 11.8: The pizza image is not part of the background, but an independent object based on the Sprite class.
Figure 11.9: A cheesy sprite, drawn on a solid-color background to take advantage of transparency.
Figure 11.10: On the left, the image is loaded with transparency on. On the right, the same image is loaded with transparency off.
Figure 11.11: The pizza falls down the screen in the direction of the arrow.
Figure 11.12: Though you can't tell from the screen shot, the pizza bounces around, following the path of the arrow.
Figure 11.13: The pan sprite follows the mouse around the graphics screen.
Figure 11.14: The player almost reaches the pizza.
Figure 11.15: The slippery pizza gets away again.

Chapter 12: Sound, Animation, and Program Development: The Astrocrash Game

Figure 12.1: The player controls a spaceship and blasts asteroids to increase his or her score. (Nebula image is in the public domain. Credit— NASA, The Hubble Heritage Team - AURA/STScI)
Figure 12.2: If an asteroid hits the player's ship, the game is over.
Figure 12.3: The ship moves around the screen based on key presses.
Figure 12.4: The ship can rotate clockwise, rotate counterclockwise, or jump to a predetermined orientation.
Figure 12.5: Although it's hard to tell from a still image, an explosion animates at the center of the graphics window.
Figure 12.6: Shown in rapid succession, these nine frames of animation look like an explosion.
Figure 12.7: The program lets the user play a sound and some music.
Figure 12.8: A field of moving asteroids is the foundation of the game.
Figure 12.9: The player's ship is now part of the action.
Figure 12.10: The ship can now move around the screen.
Figure 12.11: The missile fire rate is too high.
Figure 12.12: Now the ship fires missiles at a more reasonable rate.
Figure 12.13: The ship's missiles now destroy asteroids. But be careful, as asteroids destroy the ship.
Figure 12.14: All of the destruction in the game is now accompanied by fiery explosions.
Figure 12.15: The final touches let the game continue as long as the player's Astrocrash skills allow.




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