Contents
0.2 How Computers Work and Why We Made Them
Convert Binary Numbers to Decimal
Convert Decimal Numbers to Binary
0.3 Computer Systems Are Built in Layers
0.3.1 Assemblers and Compilers
0.3.2 Graphical User Interfaces (GUIs)
Chapter 1 Computers and Programming
1.1 Solving a Problem Using a Computer
1.5 Solving the Guess a Number Problem
1.6 Solving the Rock-Paper-Scissors Problem
1.6.1 Variables and Values – Experimenting with the Graphical User Interface
1.6.2 Exchanging Information with the Computer
1.6.3 Example 1: Draw a Circle Using Characters
1.6.4 Strings, Integers, and Real Numbers
1.6.6 Example 2: Compute the Circumference of any Circle
1.10 Types Are Dynamic (Advanced)
2.1.1 The Guess-A-Number Program Yet Again
2.2 Rock-Paper-Scissors Yet Again
2.8.1 Problem: A Final Look at Guess a Number
Chapter 3 Sequences: Strings, Tuples, and Lists
Problem: Does a City Name, Entered at the Console, Come before or after the Name Denver?
3.1.2 Slicing – Extracting Parts of Strings
Problem: Identify a “Print” Statement in a String
Problem: Create a JPEG File Name from a Basic String
Problem: Change the Suffix of a File Name
Problem: Reverse the Order of Characters in a String
Problem: Is a Given File Name That of a Python Program?
Problem: Print the Number of Neutrons in an Atomic Nucleus
Problem: What Even Numbers Less than or Equal to 100 are Also Perfect Squares?
Problem: Delete the Element Lithium from the Tuple Atoms, along with Its Atomic Number.
Problem: Change the Entry for Lithium to an Entry for Oxygen
3.3.6 Built-In Functions for Tuples
Problem: Compute the Average (Mean) of a List of Numbers
Problem: Delete the Element Helium from a List
Problem: Delete a Specified Element from a List
4.1 Function Definition: Syntax and Semantics
4.1.1 Problem: Use poundn to Draw a Histogram
4.1.2 Problem: Generalize the Histogram Code for Other Years
Problem: Write a Function to Calculate the Square Root of its Parameter
4.2.5 Example: The Game of Sticks
4.2.7 Variable Parameter Lists
Example: Find the Maximum Value of a Function
4.2.9 Functions as Return Values
4.3.1 Avoiding Infinite Recursion
4.5 Program Design Using Functions – Example: The Game of Nim
4.5.1 The Development Process Exposed
Chapter 5 Files: Input and Output
5.1 What Is a File? A Little “Theory”
5.1.1 How Are Files Stored on a Disk?
5.2.1 Problem: Read a Number from the Keyboard and Divide It by 2
5.3 Using Files in Python: Less Theory, More Practice
Problem: Print the Names of Planets Having Fewer Than Ten Moons
Problem: Play Jeopardy Using a CSV Data Set
Example: Write a Table of Squares to a File
5.4.1 Appending Data to a File
Example: Append Another 20 Squares to the Table of Squares File
6.1.1 The Python Class – Syntax and Semantics
6.2.1 Example: A Deck of Cards
6.3 Subclasses and Inheritance
6.3.1 Non-Trivial Example: Objects in a Video Game
7.1 Introduction to Graphics Programming
7.1.1 Essentials: The Graphics Window and Colors
Example: Create a Page of Notepaper
Example: Creating a Color Gradient
Example: Identifying a Green Car
8.1.1 Example: A Naive Latin – English Translation
8.1.2 Functions for Dictionaries
8.3 Formatted Text, Formatted I/O
8.3.1 Example: NASA Meteorite Landing Data
Example: Create a File of Integers
Example: A Video Game High Score File
Example: Maintaining the High Score File in Order
Example: Draw a Circle at the Mouse Cursor
Example: Change Background Color Using the Mouse
Example: Draw Lines Using the Mouse
Example: Pressing a “+” Creates a Random Circle
Example: Reading a Character String
Example: Read Frames and Play Them Back as an Animation
9.4 RGBA Colors – Transparency
Example: Control Volume Using the Keyboard. Pause and Unpause
Example: Play a Sound Effect at the Right Moment: Bounces
Example: Carclub – Display the Video carclub2.mpg (Annotated)
Exercise: Threshold a Video (Processing Pixels)
10.3.1 Linear Congruential Method
10.4.2 Public Key Encryption (RSA)
Example: Encrypt the Message “Depart at Dawn” Using RSA
Chapter 11 Programming for the Sciences
11.1 Finding Roots of Equations
11.4 Optimization: Finding Maxima and Minima
11.4.2 Fitting Data to Curves – Regression
11.5 Longest Common Subsequence (Edit Distance)
11.5.1 Determining Longest Common Subsequence (LCS)
Chapter 12 How to Write Good Programs
12.1 Procedural Programming – Word Processing
12.2 Object Oriented Programming – Breakout
12.3 Describing the Problem as a Process
12.3.1 Initial Coding for a Tile
12.3.2 Initial Coding for the Paddle
12.3.3 Initial Coding for the Ball
12.3.6 Ball and Tile Collisions
12.3.7 Ball and Paddle Collisions
Chapter 13 Communicating with the Outside World
Example: Display the Subject Headers for Emails in Inbox
Example: Download and Display the README File from an FTP Site
13.3 Communication Between Processes
Example: A Server That Calculates Squares
Example: Connect to the Twitter Stream and Print Specific Messages
13.5 Communicating with Other Languages
Example: Find Two Large Relatively Prime Numbers