Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Save to My Library
Look up keyword or section
Like this

Table Of Contents

Python Calculator
1.1 Introduction
1.2 Installing and Starting Python
1.3 Printing
1.4 Assignment Operators
Listing 1.2: Assigning and using variables
1.5 Variables
1.6 Operators
1.7 Review
Conditional Statements
2.1 Basic Comparisons
Listing 2.1: Example if statements less than greater than
Listing 2.2: Example if statements less than or equal greater than or equal
2.2 Using And/Or
Listing 2.4: Example if statements using “and” and “or”
2.3 Boolean Variables
Listing 2.5: If statements and Boolean data types
Listing 2.6: Assigning values to Boolean data types
2.4 Else and Else If
Listing 2.9: Example of improper ordering if/elif/else
2.5 Text Comparisons
Listing 2.11: Case-insensitive text comparison
3.1 for loops
Listing 3.4: Two ways to print the even numbers 2 to 10
3.2 While loops
Listing 3.7: Using a while loop to print the numbers 0 to 9
Listing 3.9: Looping until the user wants to quit
Listing 3.10: Looping until the game is over or the user wants to quit
3.2.1 Common problems with while loops
3.3 Review Questions
Introduction to Graphics
4.1 Computer coordinate systems
4.2 Pygame Library
Listing 4.1: Importing and initializing pygame
4.3 Colors
4.4 Open a window
Listing 4.3: Opening and setting the window size
Listing 4.4: Setting the window title
4.5 Interacting with the user
Listing 4.5: Setting up the main program loop
4.6 Drawing
4.7 Loops and offsets
Listing 4.7: Drawing a series of lines
4.8 Text
Listing 4.8: Drawing text on the screen
4.9 Flipping the screen
Listing 4.13: Flipping the Pygame display
4.10 Ending the program
Listing 4.14: Proper shutdown of a Pygame program
4.11 Full Listing
Back to Looping
5.1 Basic Review
5.2 Advanced looping problems
Introduction to Lists
6.1 Data Types
6.2 Working with lists
Listing 6.1: Creating a list of numbers from user input
Listing 6.2: Summing the values in a list
Listing 6.3: Doubling all the numbers in a list
6.3 Slicing strings
Listing 6.4: Accessing a string as a list
Listing 6.5: Adding and multiplying strings
Listing 6.6: Getting the length of a string or list
6.4 Secret Codes
6.5 Associative arrays
6.6 Review
Random Numbers
7.1 The randrange function
Listing 7.3: Picking a random item out of a list
7.2 The random function
Listing 7.4: Random floating point number from 0 to 1
Listing 7.5: Random floating point number between 10 and 15
Introduction to Animation
8.1 The bouncing rectangle
8.2 Animating Snow
8.2.1 Code explanation
8.2.2 Full listing
8.3 3D Animation
9.1 Introduction to functions
Listing 9.1: Function that prints the volume of a sphere
Listing 9.2: Function that prints the volume of a cylinder
Listing 9.3: Function that returns the volume of a cylinder
9.2 Variable scope
9.3 Pass-by-copy
9.4 Functions calling functions
9.5 Review
9.5.1 Predicting output
9.5.2 Correcting code
9.5.3 Writing code
Excel Macro Demonstration
10.1 Introduction
10.2 Tutorial
10.3 Code Listings
Listing 10.1: VBScript macro after recording
Listing 10.2: Modified VBScript that uses a parameter
Listing 10.3: VBScript function to create multiple charts
Controllers and Graphics
11.1 Introduction
11.2 Mouse
Listing 11.1: Controlling an object via the mouse
11.3 Keyboard
Listing 11.2: Controlling an object via the keyboard
11.4 Game Controller
Listing 11.3: Initializing the game controller for use
Listing 11.4: Controlling an object via a game controller
12.1 Introduction
12.2 Setting a Background Image
12.3 Moving an Image
12.4 Sounds
Listing 12.1: Example program using bitmapped graphics and sound
12.6 Review
Introduction to Classes
13.1 Defining and Creating Simple Classes
13.1.1 Review
13.2 Methods
13.2.1 Example: Ball class
13.3 References
13.4 Constructors
13.4.1 Review
13.5 Inheritance
Introduction to Sprites
14.2 Moving Sprites
Libraries and Modules
15.1 Creating your own module/library file:
Listing 15.1: test.py with everything in it
Listing 15.4: test.py that imports but still doesn’t work
15.2 Namespace:
Listing 15.8: test.py that calls different print report functions
15.3 Third Party Libraries
15.4 Review
Listing 16.1: Read in a file from disk and put it in an array
16.3 Linear Search
16.3.1 Review
16.4 Binary Search
16.4.1 Review
Array-nBacked Grids
17.1 Drawing the Grid
17.2 Populating the Grid
Listing 17.1: Create a 10x10 array of numbers
17.3 Final Program
Listing 17.2: Creating an array backed grid
18.1 Swapping Values
Listing 18.1: Swapping two values in an array
18.2 Selection Sort
18.3 Insertion Sort
18.4 Review
19.1 Introduction to exceptions
19.2 Exception handling
Listing 19.1: Handling division by zero
Listing 19.2: Handling number conversion errors
Listing 19.3: Better handling of number conversion errors
19.3 Example: Saving high score
19.4 Exception generating
19.5 Proper exception use
A.1 Example: High Score
Command Reference
B.1 Draw
B.1.1 pygame.draw.rect
B.1.2 pygame.draw.polygon
B.1.3 pygame.draw.circle
B.1.4 pygame.draw.ellipse
B.1.5 pygame.draw.arc
B.1.6 pygame.draw.line
B.1.7 pygame.draw.lines
B.1.8 pygame.draw.aaline
B.1.9 pygame.draw.aalines
C.1 Lab: Calculator
C.1.1 Lab 01 a
C.1.2 Lab 01 b
C.1.3 Lab 01 c
C.2 Lab: Create-a-Quiz
C.2.1 Description
C.2.2 Example Run
C.3 Lab: Create-a-Picture
C.3.1 Description
C.3.2 Example Runs
C.4 Lab: Looping
C.4.1 Requirements
C.4.2 Tips: Part 1
C.4.3 Tips: Part 2
C.4.4 Tips: Part 3
C.5 Lab: Animation
C.5.1 Requirements
C.7 Lab: Functions
C.8 Lab: Webkinz
C.8.1 Description
C.8.2 Desired Output
C.8.3 Instructions
C.9 Lab: Sprite Collecting
C.10 Lab: Spell Check
C.10.1 Requirements
C.10.2 Steps to complete:
C.10.3 Example Run
0 of .
Results for:
No results containing your search query
P. 1


Ratings: (0)|Views: 3,703|Likes:
Published by Jim Syyap

More info:

Published by: Jim Syyap on Oct 22, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





You're Reading a Free Preview
Pages 4 to 110 are not shown in this preview.
You're Reading a Free Preview
Pages 114 to 116 are not shown in this preview.
You're Reading a Free Preview
Pages 120 to 127 are not shown in this preview.
You're Reading a Free Preview
Pages 131 to 176 are not shown in this preview.
You're Reading a Free Preview
Pages 180 to 186 are not shown in this preview.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->