1 Introduction to Computer Science
What Do Computing Professionals Do?
Models, Algorithms, and Programs
Networks and Network Protocols
1.3 Python Programming Language
Setting Up the Python Development Environment
Assignments and Execution Control Structures
2.1 Expressions, Variables, and Assignments
Algebraic Expressions and Functions
Boolean Expressions and Operators
Lists Are Mutable, Strings Are Not
Class Methods and Object-Oriented Programming
2.6 Case Study: Turtle Graphics Objects
Solutions to Practice Problems
Interactive Input with input()
3.2 Execution Control Structures
Nesting Control Flow Structures
Function Definitions Are “Assignment” Statements
3.4 Python Variables and Assignments
3.6 Case Study: Automating Turtle Graphics
Solutions to Practice Problems
4 Text Data, Files, and Exceptions
The Indexing Operator, Revisited
Patterns for Reading a Text File
4.5 Case Study: Logging File Access
Getting and Formatting the Date and Time
Final Implementation of openLog()
Solutions to Practice Problems
5 Execution Control Structures
5.1 Decision Control and the if Statement
Three-Way (and More!) Decisions
5.2 for Loop and Iteration Patterns
Loop Pattern: Accumulator Loop
5.3 More on Lists: Two-Dimensional Lists
Two-Dimensional Lists and the Nested Loop Pattern
Iteration Patterns: Sequence Loop
5.6 Additional Iteration Control Statements
Solutions to Practice Problems
User-Defined Indexes as Motivation for Dictionaries
A Dictionary as a Substitute for Multiway Condition
Dictionary as a Collection of Counters
6.2 Other Built-In Container Types
tuple Objects Can Be Dictionary Keys
Dictionary Method items(), Revisited
Using the set Constructor to Remove Duplicates
6.3 Character Encodings and Strings
UTF-8 Encoding for Unicode Characters
Shuffling, Choosing, and Sampling at Random
6.5 Case Study: Games of Chance
Creating and Shuffling the Deck of Cards
Comparing the Player's and the House's Hands
Solutions to Practice Problems
7.1 Encapsulation in Functions
Modularity (or Procedural Decomposition)
Encapsulation (or Information Hiding)
Namespaces Associated with Function Calls
Namespaces and the Program Stack
7.2 Global versus Local Namespaces
Changing Global Variables Inside a Function
Exceptions and Exceptional Control Flow
Catching and Handling Exceptions
Catching Exceptions of a Given Type
Controlling the Exceptional Control Flow
What Happens When Importing a Module
Different Ways to Import Module Attributes
Class Methods Are Functions Defined in the Class Namespace
Solutions to Practice Problems
8.1 Defining a New Python Class
Every Object Has an Associated Namespace
Instances Inherit Class Attributes
Class Definition, More Generally
8.2 Examples of User-Defined Classes
Overloaded Constructor Operator
8.3 Designing New Container Classes
Designing a Class Representing a Deck of Playing Cards
Implementing the Deck (of Cards) Class
Making the Class Point User Friendly
Contract between the Constructor and the repr() Operator
Making the Queue Class User Friendly
Inheriting Attributes of a Class
Implementing a Queue Class by Inheriting from list
User-Defined Exception Classes
Improving the Encapsulation of Class Queue
8.7 Case Study: Indexing and Iterators
Overloading the Indexing Operators
Iterators and OOP Design Patterns
Solutions to Practice Problems
9.1 Basics of tkinter GUI Development
Widget Label for Displaying Text
9.2 Event-Based tkinter Widgets
Button Widget and Event Handlers
Events, Event Handlers, and mainloop()
Text Widget and Binding Events
Event Patterns and the tkinter Class Event
Widget Frame as an Organizing Widget
Shared Widgets Are Assigned to Instance Variables
Shared Data Are Assigned to Instance Variables
9.5 Case Study: Developing a Calculator
The Calculator Buttons and Passing Arguments to Handlers
Implementing the “Unofficial” Event Handler click()
Solutions to Practice Problems
10.1 Introduction to Recursion
Recursive Function Calls and the Program Stack
Recursive Number Sequence Pattern
Experimental Analysis of Run Time
10.5 Case Study: Tower of Hanoi
Solutions to Practice Problems
Naming Scheme: Uniform Resource Locator
Protocol: HyperText Transfer Protocol
Tree Structure of an HTML Document
Anchor HTML Element and Absolute Links
Overriding the HTMLParser Handlers
Parser That Collects HTTP Hyperlinks
Python Standard Library Module re
Recursive Crawler, Version 0.1
Recursive Crawler, Version 0.2
Solutions to Practice Problems
12 Databases and Data Processing
Making SQL Queries Involving Multiple Tables
12.2 Database Programming in Python
Creating a Database with sqlite3
Committing to Database Changes and Closing the Database
Querying a Database Using sqlite3
12.3 Functional Language Approach
MapReduce Problem Solving Framework
Class Pool of Module multiprocessing
Parallel versus Sequential MapReduce