Contents In Detail
Praise for Python Crash Course
Title Page
Copyright
Dedication
About the Author
Preface to the Third Edition
Acknowledgments
Introduction
Who Is This Book For?
What Can You Expect to Learn?
Online Resources
Why Python?
Part I: Basics
Chapter 1: Getting Started
Setting Up Your Programming Environment
Python Versions
Running Snippets of Python Code
About the VS Code Editor
Python on Different Operating Systems
Python on Windows
Python on macOS
Python on Linux
Running a Hello World Program
Installing the Python Extension for VS Code
Running hello_world.py
Troubleshooting
Running Python Programs from a Terminal
On Windows
On macOS and Linux
Exercise 1-1: python.org
Exercise 1-2: Hello World Typos
Exercise 1-3: Infinite Skills
Summary
Chapter 2: Variables and Simple Data Types
What Really Happens When You Run hello_world.py
Variables
Naming and Using Variables
Avoiding Name Errors When Using Variables
Variables Are Labels
Exercise 2-1: Simple Message
Exercise 2-2: Simple Messages
Strings
Changing Case in a String with Methods
Using Variables in Strings
Adding Whitespace to Strings with Tabs or Newlines
Stripping Whitespace
Removing Prefixes
Avoiding Syntax Errors with Strings
Exercise 2-3: Personal Message
Exercise 2-4: Name Cases
Exercise 2-5: Famous Quote
Exercise 2-6: Famous Quote 2
Exercise 2-7: Stripping Names
Exercise 2-8: File Extensions
Numbers
Integers
Floats
Integers and Floats
Underscores in Numbers
Multiple Assignment
Constants
Exercise 2-9: Number Eight
Exercise 2-10: Favorite Number
Comments
How Do You Write Comments?
What Kinds of Comments Should You Write?
Exercise 2-11: Adding Comments
The Zen of Python
Exercise 2-12: Zen of Python
Summary
Chapter 3: Introducing Lists
What Is a List?
Accessing Elements in a List
Index Positions Start at 0, Not 1
Using Individual Values from a List
Exercise 3-1: Names
Exercise 3-2: Greetings
Exercise 3-3: Your Own List
Modifying, Adding, and Removing Elements
Modifying Elements in a List
Adding Elements to a List
Removing Elements from a List
Exercise 3-4: Guest List
Exercise 3-5: Changing Guest List
Exercise 3-6: More Guests
Exercise 3-7: Shrinking Guest List
Organizing a List
Sorting a List Permanently with the sort() Method
Sorting a List Temporarily with the sorted() Function
Printing a List in Reverse Order
Finding the Length of a List
Exercise 3-8: Seeing the World
Exercise 3-9: Dinner Guests
Exercise 3-10: Every Function
Avoiding Index Errors When Working with Lists
Exercise 3-11: Intentional Error
Summary
Chapter 4: Working with Lists
Looping Through an Entire List
A Closer Look at Looping
Doing More Work Within a for Loop
Doing Something After a for Loop
Avoiding Indentation Errors
Forgetting to Indent
Forgetting to Indent Additional Lines
Indenting Unnecessarily
Indenting Unnecessarily After the Loop
Forgetting the Colon
Exercise 4-1: Pizzas
Exercise 4-2: Animals
Making Numerical Lists
Using the range() Function
Using range() to Make a List of Numbers
Simple Statistics with a List of Numbers
List Comprehensions
Exercise 4-3: Counting to Twenty
Exercise 4-4: One Million
Exercise 4-5: Summing a Million
Exercise 4-6: Odd Numbers
Exercise 4-7: Threes
Exercise 4-8: Cubes
Exercise 4-9: Cube Comprehension
Working with Part of a List
Slicing a List
Looping Through a Slice
Copying a List
Exercise 4-10: Slices
Exercise 4-11: My Pizzas, Your Pizzas
Exercise 4-12: More Loops
Tuples
Defining a Tuple
Looping Through All Values in a Tuple
Writing Over a Tuple
Exercise 4-13: Buffet
Styling Your Code
The Style Guide
Indentation
Line Length
Blank Lines
Other Style Guidelines
Exercise 4-14: PEP 8
Exercise 4-15: Code Review
Summary
Chapter 5: if Statements
A Simple Example
Conditional Tests
Checking for Equality
Ignoring Case When Checking for Equality
Checking for Inequality
Numerical Comparisons
Checking Multiple Conditions
Checking Whether a Value Is in a List
Checking Whether a Value Is Not in a List
Boolean Expressions
Exercise 5-1: Conditional Tests
Exercise 5-2: More Conditional Tests
if Statements
Simple if Statements
if-else Statements
The if-elif-else Chain
Using Multiple elif Blocks
Omitting the else Block
Testing Multiple Conditions
Exercise 5-3: Alien Colors #1
Exercise 5-4: Alien Colors #2
Exercise 5-5: Alien Colors #3
Exercise 5-6: Stages of Life
Exercise 5-7: Favorite Fruit
Using if Statements with Lists
Checking for Special Items
Checking That a List Is Not Empty
Using Multiple Lists
Exercise 5-8: Hello Admin
Exercise 5-9: No Users
Exercise 5-10: Checking Usernames
Exercise 5-11: Ordinal Numbers
Styling Your if Statements
Exercise 5-12: Styling if Statements
Exercise 5-13: Your Ideas
Summary
Chapter 6: Dictionaries
A Simple Dictionary
Working with Dictionaries
Accessing Values in a Dictionary
Adding New Key-Value Pairs
Starting with an Empty Dictionary
Modifying Values in a Dictionary
Removing Key-Value Pairs
A Dictionary of Similar Objects
Using get() to Access Values
Exercise 6-1: Person
Exercise 6-2: Favorite Numbers
Exercise 6-3: Glossary
Looping Through a Dictionary
Looping Through All Key-Value Pairs
Looping Through All the Keys in a Dictionary
Looping Through a Dictionary’s Keys in a Particular Order
Looping Through All Values in a Dictionary
Exercise 6-4: Glossary 2
Exercise 6-5: Rivers
Exercise 6-6: Polling
Nesting
A List of Dictionaries
A List in a Dictionary
A Dictionary in a Dictionary
Exercise 6-7: People
Exercise 6-8: Pets
Exercise 6-9: Favorite Places
Exercise 6-10: Favorite Numbers
Exercise 6-11: Cities
Exercise 6-12: Extensions
Summary
Chapter 7: User Input and while Loops
How the input() Function Works
Writing Clear Prompts
Using int() to Accept Numerical Input
The Modulo Operator
Exercise 7-1: Rental Car
Exercise 7-2: Restaurant Seating
Exercise 7-3: Multiples of Ten
Introducing while Loops
The while Loop in Action
Letting the User Choose When to Quit
Using a Flag
Using break to Exit a Loop
Using continue in a Loop
Avoiding Infinite Loops
Exercise 7-4: Pizza Toppings
Exercise 7-5: Movie Tickets
Exercise 7-6: Three Exits
Exercise 7-7: Infinity
Using a while Loop with Lists and Dictionaries
Moving Items from One List to Another
Removing All Instances of Specific Values from a List
Filling a Dictionary with User Input
Exercise 7-8: Deli
Exercise 7-9: No Pastrami
Exercise 7-10: Dream Vacation
Summary
Chapter 8: Functions
Defining a Function
Passing Information to a Function
Arguments and Parameters
Exercise 8-1: Message
Exercise 8-2: Favorite Book
Passing Arguments
Positional Arguments
Keyword Arguments
Default Values
Equivalent Function Calls
Avoiding Argument Errors
Exercise 8-3: T-Shirt
Exercise 8-4: Large Shirts
Exercise 8-5: Cities
Return Values
Returning a Simple Value
Making an Argument Optional
Returning a Dictionary
Using a Function with a while Loop
Exercise 8-6: City Names
Exercise 8-7: Album
Exercise 8-8: User Albums
Passing a List
Modifying a List in a Function
Preventing a Function from Modifying a List
Exercise 8-9: Messages
Exercise 8-10: Sending Messages
Exercise 8-11: Archived Messages
Passing an Arbitrary Number of Arguments
Mixing Positional and Arbitrary Arguments
Using Arbitrary Keyword Arguments
Exercise 8-12: Sandwiches
Exercise 8-13: User Profile
Exercise 8-14: Cars
Storing Your Functions in Modules
Importing an Entire Module
Importing Specific Functions
Using as to Give a Function an Alias
Using as to Give a Module an Alias
Importing All Functions in a Module
Styling Functions
Exercise 8-15: Printing Models
Exercise 8-16: Imports
Exercise 8-17: Styling Functions
Summary
Chapter 9: Classes
Creating and Using a Class
Creating the Dog Class
The __init__() Method
Making an Instance from a Class
Exercise 9-1: Restaurant
Exercise 9-2: Three Restaurants
Exercise 9-3: Users
Working with Classes and Instances
The Car Class
Setting a Default Value for an Attribute
Modifying Attribute Values
Exercise 9-4: Number Served
Exercise 9-5: Login Attempts
Inheritance
The __init__() Method for a Child Class
Defining Attributes and Methods for the Child Class
Overriding Methods from the Parent Class
Instances as Attributes
Modeling Real-World Objects
Exercise 9-6: Ice Cream Stand
Exercise 9-7: Admin
Exercise 9-8: Privileges
Exercise 9-9: Battery Upgrade
Importing Classes
Importing a Single Class
Storing Multiple Classes in a Module
Importing Multiple Classes from a Module
Importing an Entire Module
Importing All Classes from a Module
Importing a Module into a Module
Using Aliases
Finding Your Own Workflow
Exercise 9-10: Imported Restaurant
Exercise 9-11: Imported Admin
Exercise 9-12: Multiple Modules
The Python Standard Library
Exercise 9-13: Dice
Exercise 9-14: Lottery
Exercise 9-15: Lottery Analysis
Exercise 9-16: Python Module of the Week
Styling Classes
Summary
Chapter 10: Files and Exceptions
Reading from a File
Reading the Contents of a File
Relative and Absolute File Paths
Accessing a File’s Lines
Working with a File’s Contents
Large Files: One Million Digits
Is Your Birthday Contained in Pi?
Exercise 10-1: Learning Python
Exercise 10-2: Learning C
Exercise 10-3: Simpler Code
Writing to a File
Writing a Single Line
Writing Multiple Lines
Exercise 10-4: Guest
Exercise 10-5: Guest Book
Exceptions
Handling the ZeroDivisionError Exception
Using try-except Blocks
Using Exceptions to Prevent Crashes
The else Block
Handling the FileNotFoundError Exception
Analyzing Text
Working with Multiple Files
Failing Silently
Deciding Which Errors to Report
Exercise 10-6: Addition
Exercise 10-7: Addition Calculator
Exercise 10-8: Cats and Dogs
Exercise 10-9: Silent Cats and Dogs
Exercise 10-10: Common Words
Storing Data
Using json.dumps() and json.loads()
Saving and Reading User-Generated Data
Refactoring
Exercise 10-11: Favorite Number
Exercise 10-12: Favorite Number Remembered
Exercise 10-13: User Dictionary
Exercise 10-14: Verify User
Summary
Chapter 11: Testing Your Code
Installing pytest with pip
Updating pip
Installing pytest
Testing a Function
Unit Tests and Test Cases
A Passing Test
Running a Test
A Failing Test
Responding to a Failed Test
Adding New Tests
Exercise 11-1: City, Country
Exercise 11-2: Population
Testing a Class
A Variety of Assertions
A Class to Test
Testing the AnonymousSurvey Class
Using Fixtures
Exercise 11-3: Employee
Summary
Part II: Projects
Chapter 12: A Ship That Fires Bullets
Planning Your Project
Installing Pygame
Starting the Game Project
Creating a Pygame Window and Responding to User Input
Controlling the Frame Rate
Setting the Background Color
Creating a Settings Class
Adding the Ship Image
Creating the Ship Class
Drawing the Ship to the Screen
Refactoring: The _check_events() and _update_screen() Methods
The _check_events() Method
The _update_screen() Method
Exercise 12-1: Blue Sky
Exercise 12-2: Game Character
Piloting the Ship
Responding to a Keypress
Allowing Continuous Movement
Moving Both Left and Right
Adjusting the Ship’s Speed
Limiting the Ship’s Range
Refactoring _check_events()
Pressing Q to Quit
Running the Game in Fullscreen Mode
A Quick Recap
alien_invasion.py
settings.py
ship.py
Exercise 12-3: Pygame Documentation
Exercise 12-4: Rocket
Exercise 12-5: Keys
Shooting Bullets
Adding the Bullet Settings
Creating the Bullet Class
Storing Bullets in a Group
Firing Bullets
Deleting Old Bullets
Limiting the Number of Bullets
Creating the _update_bullets() Method
Exercise 12-6: Sideways Shooter
Summary
Chapter 13: Aliens!
Reviewing the Project
Creating the First Alien
Creating the Alien Class
Creating an Instance of the Alien
Building the Alien Fleet
Creating a Row of Aliens
Refactoring _create_fleet()
Adding Rows
Exercise 13-1: Stars
Exercise 13-2: Better Stars
Making the Fleet Move
Moving the Aliens Right
Creating Settings for Fleet Direction
Checking Whether an Alien Has Hit the Edge
Dropping the Fleet and Changing Direction
Exercise 13-3: Raindrops
Exercise 13-4: Steady Rain
Shooting Aliens
Detecting Bullet Collisions
Making Larger Bullets for Testing
Repopulating the Fleet
Speeding Up the Bullets
Refactoring _update_bullets()
Exercise 13-5: Sideways Shooter Part 2
Ending the Game
Detecting Alien-Ship Collisions
Responding to Alien-Ship Collisions
Aliens That Reach the Bottom of the Screen
Game Over!
Identifying When Parts of the Game Should Run
Exercise 13-6: Game Over
Summary
Chapter 14: Scoring
Adding the Play Button
Creating a Button Class
Drawing the Button to the Screen
Starting the Game
Resetting the Game
Deactivating the Play Button
Hiding the Mouse Cursor
Exercise 14-1: Press P to Play
Exercise 14-2: Target Practice
Leveling Up
Modifying the Speed Settings
Resetting the Speed
Exercise 14-3: Challenging Target Practice
Exercise 14-4: Difficulty Levels
Scoring
Displaying the Score
Making a Scoreboard
Updating the Score as Aliens Are Shot Down
Resetting the Score
Making Sure to Score All Hits
Increasing Point Values
Rounding the Score
High Scores
Displaying the Level
Displaying the Number of Ships
Exercise 14-5: All-Time High Score
Exercise 14-6: Refactoring
Exercise 14-7: Expanding the Game
Exercise 14-8: Sideways Shooter, Final Version
Summary
Chapter 15: Generating Data
Installing Matplotlib
Plotting a Simple Line Graph
Changing the Label Type and Line Thickness
Correcting the Plot
Using Built-in Styles
Plotting and Styling Individual Points with scatter()
Plotting a Series of Points with scatter()
Calculating Data Automatically
Customizing Tick Labels
Defining Custom Colors
Using a Colormap
Saving Your Plots Automatically
Exercise 15-1: Cubes
Exercise 15-2: Colored Cubes
Random Walks
Creating the RandomWalk Class
Choosing Directions
Plotting the Random Walk
Generating Multiple Random Walks
Styling the Walk
Exercise 15-3: Molecular Motion
Exercise 15-4: Modified Random Walks
Exercise 15-5: Refactoring
Rolling Dice with Plotly
Installing Plotly
Creating the Die Class
Rolling the Die
Analyzing the Results
Making a Histogram
Customizing the Plot
Rolling Two Dice
Further Customizations
Rolling Dice of Different Sizes
Saving Figures
Exercise 15-6: Two D8s
Exercise 15-7: Three Dice
Exercise 15-8: Multiplication
Exercise 15-9: Die Comprehensions
Exercise 15-10: Practicing with Both Libraries
Summary
Chapter 16: Downloading Data
The CSV File Format
Parsing the CSV File Headers
Printing the Headers and Their Positions
Extracting and Reading Data
Plotting Data in a Temperature Chart
The datetime Module
Plotting Dates
Plotting a Longer Timeframe
Plotting a Second Data Series
Shading an Area in the Chart
Error Checking
Downloading Your Own Data
Exercise 16-1: Sitka Rainfall
Exercise 16-2: Sitka–Death Valley Comparison
Exercise 16-3: San Francisco
Exercise 16-4: Automatic Indexes
Exercise 16-5: Explore
Mapping Global Datasets: GeoJSON Format
Downloading Earthquake Data
Examining GeoJSON Data
Making a List of All Earthquakes
Extracting Magnitudes
Extracting Location Data
Building a World Map
Representing Magnitudes
Customizing Marker Colors
Other Color Scales
Adding Hover Text
Exercise 16-6: Refactoring
Exercise 16-7: Automated Title
Exercise 16-8: Recent Earthquakes
Exercise 16-9: World Fires
Summary
Chapter 17: Working with APIs
Using an API
Git and GitHub
Requesting Data Using an API Call
Installing Requests
Processing an API Response
Working with the Response Dictionary
Summarizing the Top Repositories
Monitoring API Rate Limits
Visualizing Repositories Using Plotly
Styling the Chart
Adding Custom Tooltips
Adding Clickable Links
Customizing Marker Colors
More About Plotly and the GitHub API
The Hacker News API
Exercise 17-1: Other Languages
Exercise 17-2: Active Discussions
Exercise 17-3: Testing python_repos.py
Exercise 17-4: Further Exploration
Summary
Chapter 18: Getting Started with Django
Setting Up a Project
Writing a Spec
Creating a Virtual Environment
Activating the Virtual Environment
Installing Django
Creating a Project in Django
Creating the Database
Viewing the Project
Exercise 18-1: New Projects
Starting an App
Defining Models
Activating Models
The Django Admin Site
Defining the Entry Model
Migrating the Entry Model
Registering Entry with the Admin Site
The Django Shell
Exercise 18-2: Short Entries
Exercise 18-3: The Django API
Exercise 18-4: Pizzeria
Making Pages: The Learning Log Home Page
Mapping a URL
Writing a View
Writing a Template
Exercise 18-5: Meal Planner
Exercise 18-6: Pizzeria Home Page
Building Additional Pages
Template Inheritance
The Topics Page
Individual Topic Pages
Exercise 18-7: Template Documentation
Exercise 18-8: Pizzeria Pages
Summary
Chapter 19: User Accounts
Allowing Users to Enter Data
Adding New Topics
Adding New Entries
Editing Entries
Exercise 19-1: Blog
Setting Up User Accounts
The accounts App
The Login Page
Logging Out
The Registration Page
Exercise 19-2: Blog Accounts
Allowing Users to Own Their Data
Restricting Access with @login_required
Connecting Data to Certain Users
Restricting Topics Access to Appropriate Users
Protecting a User’s Topics
Protecting the edit_entry Page
Associating New Topics with the Current User
Exercise 19-3: Refactoring
Exercise 19-4: Protecting new_entry
Exercise 19-5: Protected Blog
Summary
Chapter 20: Styling and Deploying an App
Styling Learning Log
The django-bootstrap5 App
Using Bootstrap to Style Learning Log
Modifying base.html
Styling the Home Page Using a Jumbotron
Styling the Login Page
Styling the Topics Page
Styling the Entries on the Topic Page
Exercise 20-1: Other Forms
Exercise 20-2: Stylish Blog
Deploying Learning Log
Making a Platform.sh Account
Installing the Platform.sh CLI
Installing platformshconfig
Creating a requirements.txt File
Additional Deployment Requirements
Adding Configuration Files
Modifying settings.py for Platform.sh
Using Git to Track the Project’s Files
Creating a Project on Platform.sh
Pushing to Platform.sh
Viewing the Live Project
Refining the Platform.sh Deployment
Creating Custom Error Pages
Ongoing Development
Deleting a Project on Platform.sh
Exercise 20-3: Live Blog
Exercise 20-4: Extended Learning Log
Summary
Appendix A: Installation and Troubleshooting
Python on Windows
Using py Instead of python
Rerunning the Installer
Python on macOS
Accidentally Installing Apple’s Version of Python
Python 2 on Older Versions of macOS
Python on Linux
Using the Default Python Installation
Installing the Latest Version of Python
Checking Which Version of Python You’re Using
Python Keywords and Built-in Functions
Python Keywords
Python Built-in Functions
Appendix B: Text Editors and IDEs
Working Efficiently with VS Code
Configuring VS Code
VS Code Shortcuts
Other Text Editors and IDEs
IDLE
Geany
Sublime Text
Emacs and Vim
PyCharm
Jupyter Notebooks
Appendix C: Getting Help
First Steps
Try It Again
Take a Break
Refer to This Book’s Resources
Searching Online
Stack Overflow
The Official Python Documentation
Official Library Documentation
r/learnpython
Blog Posts
Discord
Slack
Appendix D: Using Git for Version Control
Installing Git
Configuring Git
Making a Project
Ignoring Files
Initializing a Repository
Checking the Status
Adding Files to the Repository
Making a Commit
Checking the Log
The Second Commit
Abandoning Changes
Checking Out Previous Commits
Deleting the Repository
Appendix E: Troubleshooting Deployments
Understanding Deployments
Basic Troubleshooting
Follow Onscreen Suggestions
Read the Log Output
OS-Specific Troubleshooting
Deploying from Windows
Deploying from macOS
Deploying from Linux
Other Deployment Approaches
Index
List of Tables
Table 11-1: Commonly Used Assertion Statements in Tests
Table 16-1: Date and Time Formatting Arguments from the
datetime
Module
List of Illustrations
Figure 1-1: Make sure you select the checkbox labeled
Add Python to PATH
.
Figure 12-1: The ship for
Alien Invasion
Figure 12-2:
Alien Invasion
with the ship at the bottom center of the screen
Figure 12-3: The ship after firing a series of bullets
Figure 13-1: The alien we’ll use to build the fleet
Figure 13-2: The first alien appears.
Figure 13-3: The first row of aliens
Figure 13-4: The full fleet appears.
Figure 13-5: We can shoot aliens!
Figure 13-6: Extra-powerful bullets make some aspects of the game easier to test.
Figure 14-1: A Play button appears when the game is inactive.
Figure 14-2: The score appears at the top-right corner of the screen.
Figure 14-3: A rounded score with comma separators
Figure 14-4: The high score is shown at the top center of the screen.
Figure 14-5: The current level appears just below the current score.
Figure 14-6: The complete scoring system for
Alien Invasion
Figure 15-1: One of the simplest plots you can make in Matplotlib
Figure 15-2: The chart is much easier to read now.
Figure 15-3: The data is now plotted correctly.
Figure 15-4: The built-in seaborn style
Figure 15-5: Plotting a single point
Figure 15-6: A scatter plot with multiple points
Figure 15-7: Python can plot 1,000 points as easily as it plots 5 points.
Figure 15-8: A plot using the
Blues
colormap
Figure 15-9: A random walk with 5,000 points
Figure 15-10: A random walk colored with the
Blues
colormap
Figure 15-11: A walk with 50,000 points
Figure 15-12: The initial plot produced by Plotly Express
Figure 15-13: A simple bar chart created with Plotly
Figure 15-14: Simulated results of rolling two six-sided dice 1,000 times
Figure 15-15: The results of rolling a six-sided die and a ten-sided die 50,000 times
Figure 16-1: A line graph showing daily high temperatures for July 2021 in Sitka, Alaska
Figure 16-2: The graph is more meaningful, now that it has dates on the
x
-axis.
Figure 16-3: A year’s worth of data
Figure 16-4: Two data series on the same plot
Figure 16-5: The region between the two datasets is shaded.
Figure 16-6: Daily high and low temperatures for Death Valley
Figure 16-7: A simple map showing where all the earthquakes in the last 24 hours occurred
Figure 16-8: The map now shows the magnitude of all earthquakes in the last 30 days.
Figure 16-9: In 30 days’ worth of earthquakes, color and size are used to represent the magnitude of each earthquake.
Figure 16-10: The hover text now includes a summary of each earthquake.
Figure 17-1: The most-starred Python projects on GitHub
Figure 17-2: A title has been added to the main chart, and to each axis as well.
Figure 17-3: Hovering over a bar shows the project’s owner and description.
Figure 18-1: Everything is working so far.
Figure 18-2: The admin site with
Topic
included
Figure 18-3: The home page for Learning Log
Figure 18-4: The topics page
Figure 18-5: The detail page for a single topic, showing all entries for a topic
Figure 19-1: The page for adding a new topic
Figure 19-2: The
new_entry
page
Figure 19-3: Each entry now has a link for editing that entry.
Figure 19-4: The login page
Figure 20-1: The Learning Log home page using Bootstrap
Figure 20-2: The login page styled with Bootstrap
Figure 20-3: The topic page with Bootstrap styling
List of Listings
Guide
Cover
Front Matter
Dedication
Preface to the Third Edition
Introduction
Part I: Basics
Chapter 1: Getting Started
Start Reading
Chapter 2: Variables and Simple Data Types
Chapter 3: Introducing Lists
Chapter 4: Working with Lists
Chapter 5: if Statements
Chapter 6: Dictionaries
Chapter 7: User Input and while Loops
Chapter 8: Functions
Chapter 9: Classes
Chapter 10: Files and Exceptions
Chapter 11: Testing Your Code
Part II: Projects
Chapter 12: A Ship That Fires Bullets
Chapter 13: Aliens!
Chapter 14: Scoring
Chapter 15: Generating Data
Chapter 16: Downloading Data
Chapter 17: Working with APIs
Chapter 18: Getting Started with Django
Chapter 19: User Accounts
Chapter 20: Styling and Deploying an App
Appendix A: Installation and Troubleshooting
Appendix B: Text Editors and IDEs
Appendix C: Getting Help
Appendix D: Using Git for Version Control
Appendix E: Troubleshooting Deployments
Index
Pages
i
iii
iv
v
vii
xxvii
xxviii
xxix
xxxi
xxxii
xxxiii
xxxiv
xxxv
xxxvi
1
2
3
4
5
6
7
8
9
10
11
12
13
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
469
470
471
472
473
474
475
477
478
479
480
481
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
503
504
505
506
507
508
509
510
511
512
513
514