Python Crash Course : A Hands-On, Project-Based Introduction to Programming 🔍
Eric Matthes No Starch Press, Incorporated, 1, PS, 2015
English [en] · PDF · 5.6MB · 2015 · 📘 Book (non-fiction) · 🚀/lgli/lgrs/nexusstc/upload/zlib · Save
description
__Python Crash Course__ is a fast-paced, thorough introduction to programming with Python that will have you writing programs, solving problems, and making things that work in no time.
In the first half of the book, you'll learn about basic programming concepts, such as lists, dictionaries, classes, and loops, and practice writing clean and readable code with exercises for each topic. You'll also learn how to make your programs interactive and how to test your code safely before adding it to a project. In the second half of the book, you'll put your new knowledge into practice with three substantial projects: a Space Invaders-inspired arcade game, data visualizations with Python's super-handy libraries, and a simple web app you can deploy online.
As you work through __Python Crash Course__, you'll learn how to:
* Use powerful Python libraries and tools, including matplotlib, NumPy, and Pygal
* Make 2D games that respond to keypresses and mouse clicks, and that grow more difficult as the game progresses
* Work with data to generate interactive visualizations
* Create and customize simple web apps and deploy them safely online
* Deal with mistakes and errors so you can solve your own programming problems
If you've been thinking seriously about digging into programming, __Python Crash Course__ will get you up to speed and have you writing real programs fast. Why wait any longer? Start your engines and code!
Alternative filename
upload/misc/utolica.duckdns.org/Eric Matthes_Python Crash Course_ A Hands-On, Project-Based Introduction to Programming.pdf
Alternative filename
nexusstc/Python Crash Course: A Hands-On, Project-Based Introduction to Programming/c9c56b6e818866210ef21c590b965698.pdf
Alternative filename
lgli/1593276036.pdf
Alternative filename
lgrsnf/1593276036.pdf
Alternative filename
zlib/Computers/Programming/Eric Matthes/Python Crash Course: A Hands-On, Project-Based Introduction to Programming_5156737.pdf
Alternative title
Изучаем Python: программирование игр, визуализация данных, веб-приложения: [12+]
Alternative title
lol
Alternative author
Эрик Мэтиз; [перевел с английского Е. Матвеев]
Alternative author
Adobe InDesign CS5.5 (7.5.3)
Alternative author
Matthes, Eric
Alternative author
Мэтиз, Эрик
Alternative publisher
Питер
Alternative edition
Библиотека программиста, 2-е изд., Санкт-Петербург [и др.], Russia, 2020
Alternative edition
Библиотека программиста, 2-е изд., Санкт-Петербург [и др.], Russia, 2018
Alternative edition
Penguin Random House LLC (Publisher Services), San Francisco, CA, 2016
Alternative edition
Серия "Библиотека программиста", Санкт-Петербург [и др.], Russia, 2017
Alternative edition
United States, United States of America
metadata comments
0
metadata comments
lg1437027
metadata comments
producers:
Adobe PDF Library 9.9
metadata comments
{"edition":"1","isbns":["1593276036","9781593276034"],"last_page":560,"publisher":"No Starch Press"}
metadata comments
На тит. л. и обл.: No starch press. Бестселлер
Фактическая дата выхода в свет - 2016
Пер.: Matthes, Eric Python crash course 978-1593276034
metadata comments
РГБ
metadata comments
Russian State Library [rgb] MARC:
=001 008670009
=005 20161108103221.0
=008 161101s2017\\\\ru\\\\\\\\\\\\000\|\rus\d
=017 \\ $a 16-83054 $b RuMoRKP
=020 \\ $a 978-5-496-02305-4 $c 1000 экз.
=040 \\ $a RuMoRGB $b rus $e rcr $d RuMoRGB
=041 1\ $a rus $h eng
=044 \\ $a ru $a bw
=080 \\ $a 004.4
=084 \\ $a З973.2-018.19Python,0 $2 rubbk
=100 1\ $a Мэтиз, Эрик
=245 00 $a Изучаем Python $h [Текст] : $b программирование игр, визуализация данных, веб-приложения : [12+] $c Эрик Мэтиз ; [пер. с англ. Е. Матвеев]
=260 \\ $a Санкт-Петербург [и др.] $b Питер $c 2017
=300 \\ $a 491, [1] с. $b ил., табл. $c 24 см
=336 \\ $a текст (text) $b txt $2 rdacontent
=337 \\ $a неопосредованный (unmediated) $b n $2 rdamedia
=338 \\ $a том (volume) $b nc $2 rdacarrier
=490 0\ $a Серия "Библиотека программиста"
=500 \\ $a На тит. л. и обл.: No starch press. Бестселлер
=500 \\ $a Фактическая дата выхода в свет - 2016
=534 \\ $p Пер.: $a Matthes, Eric $t Python crash course $z 978-1593276034
=650 \7 $a Вычислительная техника -- Вычислительные машины электронные цифровые -- Программирование -- Языки программирования -- Python $2 rubbk
=650 \7 $a PYTHON, язык программирования $0 RU\NLR\AUTH\661326547 $2 nlr_sh
=852 \\ $a РГБ $b FB $j 3 16-34/165 $x 90
metadata comments
Фактическая дата выхода в свет - 2019
Пер.: Matthes, Eric Python crash course San Francisco : no starch press, cop. 2016 978-1593276034
metadata comments
Russian State Library [rgb] MARC:
=001 010075067
=005 20190911145040.0
=008 190829s2020\\\\ru\||||\\\\\\|0||\|\rus|d
=017 \\ $a КН-П-19-062878 $b RuMoRKP
=020 \\ $a 978-5-4461-0479-6
=040 \\ $a RuMoRGB $b rus $e rcr
=041 1\ $a rus $h eng
=084 \\ $a З973.2-018.19Python,0 $2 rubbk
=100 1\ $a Мэтиз, Эрик
=245 00 $a Изучаем Python : $b программирование игр, визуализация данных, веб-приложения : [12+] $c Эрик Мэтиз ; [перевел с английского Е. Матвеев]
=250 \\ $a 2-е изд.
=260 \\ $a Санкт-Петербург [и др.] $b Питер $c 2020
=300 \\ $a 491, [1] с. $b ил. $c 24 см
=336 \\ $a Текст (визуальный)
=337 \\ $a непосредственный
=490 0\ $a Библиотека программиста
=500 \\ $a Фактическая дата выхода в свет - 2019
=534 \\ $p Пер.: $a Matthes, Eric $t Python crash course $c San Francisco : no starch press, cop. 2016 $z 978-1593276034
=650 \7 $a Техника. Технические науки -- Энергетика. Радиоэлектроника -- Радиоэлектроника -- Вычислительная техника -- Вычислительные машины электронные цифровые -- Программирование -- Языки программирования -- Python $2 rubbk
=852 \\ $a РГБ $b FB $j 3 19-48/153 $x 90
=852 7\ $a РГБ $b CZ2 $h З973.2-018/М97 $x 82
metadata comments
Пер.: Matthes, Eric Python crash course San Francisco : no starch press, cop. 2016 978-1593276034
metadata comments
Russian State Library [rgb] MARC:
=001 009689990
=005 20181017115848.0
=008 180718s2018\\\\ru\\\\\\\\\\\\0||\|\rus|d
=017 \\ $a КН-П-18-075094 $b RuMoRKP
=017 \\ $a КН-П-18-051343 $b RuMoRKP
=020 \\ $a 978-5-4461-0479-6
=040 \\ $a RuMoRGB $b rus $e rcr $d RuMoRGB
=041 1\ $a rus $h eng
=044 \\ $a ru
=084 \\ $a З973.2-018.19Python,0 $2 rubbk
=100 1\ $a Мэтиз, Эрик
=245 00 $a Изучаем Python $h [Текст] : $b программирование игр, визуализация данных, веб-приложения : [12+] $c Эрик Мэтиз ; [перевел с английского Е. Матвеев]
=250 \\ $a 2-е изд.
=260 \\ $a Санкт-Петербург [и др.] $b Питер $c 2018
=300 \\ $a 491, [1] с. $b ил., табл. $c 24 см
=336 \\ $a текст (text) $b txt $2 rdacontent
=337 \\ $a неопосредованный (unmediated) $b n $2 rdamedia
=338 \\ $a том (volume) $b nc $2 rdacarrier
=490 0\ $a Библиотека программиста
=534 \\ $p Пер.: $a Matthes, Eric $t Python crash course $c San Francisco : no starch press, cop. 2016 $z 978-1593276034
=650 \7 $a Вычислительная техника -- Вычислительные машины электронные цифровые -- Программирование -- Языки программирования -- Python $2 rubbk
=852 \\ $a РГБ $b FB $j 3 18-29/130 $x 90
=852 \\ $a РГБ $b ORF $x 82
=852 \\ $a РГБ $b ORF $x 82
Alternative description
About the Author 6
About the Technical Reviewer 6
Brief Contents 10
Contents in Detail 12
Acknowledgments 28
Introduction 30
Who Is This Book For? 31
What Can You Expect to Learn? 31
Why Python? 32
Part I: Basics 34
Chapter 1: Getting Started 36
Setting Up Your Programming Environment 36
Python 2 and Python 3 37
Running Snippets of Python Code 37
Hello World! 37
Python on Different Operating Systems 38
Python on Linux 38
Python on OS X 41
Python on Windows 43
Troubleshooting Installation Issues 48
Running Python Programs from a Terminal 49
On Linux and OS X 49
On Windows 49
Exercise 1-1: python.org 50
Exercise 1-2: Hello World Typos 50
Exercsie 1-3: Infinite Skills 50
Summary 50
Chapter 2: Variables and Simple Data Types 52
What Really Happens When You Run hello_world.py 52
Variables 53
Naming and Using Variables 54
Avoiding Name Errors When Using Variables 54
Exercise 2-1: Simple Message 56
Exercise 2-2: Simple Messages 56
Strings 56
Changing Case in a String with Methods 57
Combining or Concatenating Strings 58
Adding Whitespace to Strings with Tabs or Newlines 59
Stripping Whitespace 59
Avoiding Syntax Errors with Strings 61
Printing in Python 2 62
Exercise 2-3: Personal Message 62
Exercise 2-4: Name Cases 62
Exercise 2-5: Famous Quotes 62
Exercise 2-6: Famous Quote 2 62
Exercise 2-7: Stripping Names 62
Numbers 63
Integers 63
Floats 63
Avoiding Type Errors with the str() Function 64
Integers in Python 2 65
Exercise 2-8: Number Eight 66
Exercise 2-9: Favorite Number 66
Comments 66
How Do You Write Comments? 66
What Kind of Comments Should You Write? 66
Exercise 2-10: Adding Comments 67
The Zen of Python 67
Exercise 2-11: Zen of Python 69
Summary 69
Chapter 3: Introducing Lists 70
What Is a List? 70
Accessing Elements in a List 71
Index Positions Start at 0, Not 1 72
Using Individual Values from a List 72
Exercise 3-1: Names 73
Exercise 3-2: Greetings 73
Exercise 3-3: Your Own List 73
Changing, Adding, and Removing Elements 73
Modifying Elements in a List 73
Adding Elements to a List 74
Removing Elements from a List 75
Exercise 3-4: Guest List 79
Exercise 3-5: Changing Guest List 79
Exercise 3-6: More Guests 79
Exercsie 3-7: Shrinking Guest List 80
Organizing a List 80
Sorting a List Permanently with the sort() Method 80
Sorting a List Temporarily with the sorted() Function 81
Printing a List in Reverse Order 82
Finding the Length of a List 82
Exercise 3-8: Seeing the World 83
Exercise 3-9: Dinner Guests 83
Exercise 3-10: Every Function 83
Avoiding Index Errors When Working with Lists 83
Exercise 3-11: Intentional Error 85
Summary 85
Chapter 4: Working with Lists 86
Looping Through an Entire List 86
A Closer Look at Looping 87
Doing More Work Within a for Loop 88
Doing Something After a for Loop 89
Avoiding Indentation Errors 90
Forgetting to Indent 90
Forgetting to Indent Additional Lines 91
Indenting Unnecessarily 92
Indenting Unnecessarily After the Loop 92
Forgetting the Colon 93
Exercise 4-1: Pizzas 93
Exercise 4-2: Animals 93
Making Numerical Lists 94
Using the range() Function 94
Using range() to Make a List of Numbers 95
Simple Statistics with a List of Numbers 96
List Comprehensions 96
Exercise 4-3: Counting to Twenty 97
Exercise 4-4: One Million 97
Exercise 4-5: Summing a Million 97
Exercise 4-6: Odd Numbers 97
Exercise 4-7: Threes 97
Exercise 4-8: Cubes 97
Exercise 4-9: Cube Comprehension 97
Working with Part of a List 98
Slicing a List 98
Looping Through a Slice 99
Copying a List 100
Exercise 4-10: Slices 102
Exercise 4-11: My Pizzas, Your Pizzas 102
Exercise 4-12: More Loops 102
Tuples 102
Defining a Tuple 102
Looping Through All Values in a Tuple 103
Writing over a Tuple 104
Exercise 4-13: Buffet 104
Styling Your Code 105
The Style Guide 105
Indentation 105
Line Length 106
Blank Lines 106
Other Style Guidelines 106
Exercise 4-14: PEP 8 107
Exercise 4-15: Code Review 107
Summary 107
Chapter 5: if Statements 108
A Simple Example 109
Conditional Tests 109
Checking for Equality 109
Ignoring Case When Checking for Equality 110
Checking for Inequality 111
Numerical Comparisons 111
Checking Multiple Conditions 112
Checking Whether a Value Is in a List 113
Checking Whether a Value Is Not in a List 114
Boolean Expressions 114
Exercise 5-1: Conditional Tests 115
Exercise 5-2: More Conditional Tests 115
if Statements 115
Simple if Statements 115
if-else Statements 116
The if-elif-else Chain 117
Using Multiple elif Blocks 119
Omitting the else Block 119
Testing Multiple Conditions 120
Exercise 5-3: Alien Colors #1 121
Exercise 5-4: Alien Colors #2 121
Exercise 5-5: Alien Colors #3 122
Exercise 5-6: Stages of Life 122
Exercise 5-7: Favorite Fruit 122
Using if Statements with Lists 122
Checking for Special Items 123
Checking That a List Is Not Empty 124
Using Multiple Lists 125
Exercise 5-8: Hello Admin 126
Exercise 5-9: No Users 126
Exercise 5-10: Checking Usernames 126
Exercise 5-11: Ordinal Numbers 126
Styling Your if Statements 127
Exercise 5-12: Styling if statements 127
Exercise 5-13: Your Ideas 127
Summary 127
Chapter 6: Dictionaries 128
A Simple Dictionary 129
Working with Dictionaries 129
Accessing Values in a Dictionary 130
Adding New Key-Value Pairs 130
Starting with an Empty Dictionary 131
Modifying Values in a Dictionary 132
Removing Key-Value Pairs 133
A Dictionary of Similar Objects 133
Exercise 6-1: Person 135
Exercise 6-2: Favorite Numbers 135
Exercise 6-3: Glossary 135
Looping Through a Dictionary 135
Looping Through All Key-Value Pairs 136
Looping Through All the Keys in a Dictionary 137
Looping Through a Dictionary's Keys in Order 139
Looping Through All Values in a Dictionary 140
Exercise 6-4: Glossary 2 141
Exercise 6-5: Rivers 141
Exercise 6-6: Polling 141
Nesting 142
A List of Dictionaries 142
A List in a Dictionary 144
A Dictionary in a Dictionary 146
Exercise 6-7: People 147
Exercise 6-8: Pets 148
Exercise 6-9: Favorite Places 148
Exercise 6-10: Favorite Numbers 148
Exercise 6-11: Cities 148
Exercise 6-12: Extensions 148
Summary 148
Chapter 7: User Input and while Loops 150
How the input() Function Works 151
Writing Clear Prompts 151
Using int() to Accept Numerical Input 152
The Modulo Operator 153
Accepting Input in Python 2.7 154
Exercise 7-1: Rental Car 154
Exercise 7-2: Restaurant Seating 154
Exercise 7-3: Multiples of Ten 154
Introducing while Loops 155
The while Loop in Action 155
Letting the User Choose When to Quit 155
Using a Flag 157
Using break to Exit a Loop 158
Using continue in a Loop 159
Avoiding Infinite Loops 159
Exercise 7-4: Pizza Toppings 160
Exercise 7-5: Movie Tickets 160
Exercise 7-6: Three Exits 161
Exercise 7-7: Infinity 161
Using a while Loop with Lists and Dictionaries 161
Moving Items from One List to Another 161
Removing All Instances of Specific Values from a List 162
Filing a Dictionary with User Input 163
Exercise 7-8: Deli 164
Exercise 7-9: No Pastrami 164
Exercise 7-10: Dream Vacation 164
Summary 164
Chapter 8: Functions 166
Defining a Function 167
Passing Information to a Function 167
Arguments and Parameters 168
Exercise 8-1: Message 168
Exercise 8-2: Favorite Book 168
Passing Arguments 168
Positional Arguments 169
Keyword Arguments 170
Default Values 171
Equivalent Function Calls 172
Avoiding Argument Errors 173
Exercise 8-3: T-Shirt 174
Exercise 8-4: Large Shirts 174
Exercise 8-5: Cities 174
Return Values 174
Returning a Simple Value 175
Making an Argument Optional 175
Returning a Dictionary 177
Using a Function with a while Loop 178
Exercise 8-6: City Names 179
Exercise 8-7: Album 179
Exercise 8-8: User Albums 179
Passing a List 180
Modifying a List in a Function 180
Preventing a Function from Modifying a List 182
Exercise 8-9: Magicians 183
Exercise 8-10: Great Magicians 183
Exercise 8-11: Unchanged Magicians 183
Passing an Arbitrary Number of Arguments 184
Mixing Positional and Arbitrary Arguments 185
Using Arbitrary Keyword Arguments 185
Exercise 8-12: Sandwiches 187
Exercise 8-13: User Profile 187
Exercise 8-14: Cars 187
Storing Your Functions in Modules 187
Importing an Entire Module 187
Importing Specific Functions 189
Using as to Give a Function an Alias 189
Using as to Give a Module an Alias 190
Importing All Functions in a Module 190
Styling Functions 191
Exercise 8-15: Printing Models 192
Exercise 8-16: Imports 192
Exercise 8-17: Styling Functions 192
Summary 192
Chapter 9: Classes 194
Creating and Using a Class 195
Creating the Dog Class 195
Making an Instance from a Class 197
Exercise 9-1: Restaurant 199
Exercise 9-2: Three Restaurants 199
Exercise 9-3: Users 199
Working with Classes and Instances 200
The Car Class 200
Setting a Default Value for an Attribute 201
Modifying Attribute Values 201
Exercise 9-4: Number Served 204
Exercise 9-5: Login Attempts 204
Inheritance 205
The __init__() method for a Child Class 205
Inheritance in Python 2.7 206
Defining Attributes and Methods for the Child Class 207
Overriding Methods from the Parent Class 208
Instances as Attributes 208
Modeling Real-World Objects 210
Exercise 9-6: Ice Cream Stand 211
Exercise 9-7: Admin 211
Exercise 9-8: Privileges 211
Exercise 9-9: Battery Upgrade 211
Importing Classes 212
Importing a Single Class 212
Storing Multiple Classes in a Module 213
Importing Multiple Classes from a Module 214
Importing an Entire Module 215
Importing All Classes from a Module 215
Importing a Module into a Module 216
Finding Your Own Workflow 217
Exercise 9-10: Imported Restaurant 217
Exercise 9-11: Imported Admin 217
Exercise 9-12: Multiple Modules 217
The Python Standard Library 217
Exercise 9-13: OrderedDict Rewrite 219
Exercise 9-14: Dice 219
Exercise 9-15: Python Module of the Week 219
Styling Classes 219
Summary 220
Chapter 10: Files and Exceptions 222
Reading from a File 223
Reading an Entire File 223
File Paths 224
Reading Line by Line 226
Making a List of Lines from a File 227
Working with a File's Contents 227
Large Files: One Million Digits 228
Is Your Birthday Contained in Pi? 229
Exercise 10-1: Learning Python 230
Exercise 10-2: Learning C 230
Writing to a File 230
Writing to an Empty File 230
Writing Multiple Lines 231
Appending to a File 232
Exercise 10-3: Guest 232
Exercise 10-4: Guest Book 232
Exercise 10-5: Programming Poll 232
Exceptions 233
Handling the ZeroDivisionError Exception 233
Using try-except Blocks 233
Using Exceptions to Prevent Crashes 234
The else Block 235
Handling the FileNotFoundError Exception 236
Analyzing Text 237
Working with Multiple Files 238
Failing Silently 239
Deciding Which Errors to Report 240
Exercise 10-6: Addition 240
Exercise 10-7: Addition Calculator 241
Exercise 10-8: Cats and Dogs 241
Exercise 10-9: Silent Cats and Dogs 241
Exercise 10-10: Common Words 241
Storing Data 241
Using json.dump() and json.load() 242
Saving and Reading User-Generated Data 243
Refactoring 245
Exercise 10-11: Favorite Number 247
Exercise 10-12: Favorite Number Revisited 247
Exercise 10-13: Verify User 247
Summary 247
Chapter 11: Testing Your Code 248
Testing a Function 249
Unit Tests and Test Cases 250
A Passing Test 250
A Failing Test 251
Responding to a Failing Test 252
Adding New Tests 254
Exercise 11-1: City, Country 255
Exercise 11-2: Population 255
Testing a Class 255
A Variety of Assert Methods 255
A Class to Test 256
Testing the AnonymousSurvey Class 258
The setUp() Method 260
Exercise 11-3: Employee 261
Summary 261
Part II: Projects 264
Project 1: Alien Invasion 266
Chapter 12: A Ship that Fires Bullets 268
Planning Your Project 269
Installing Pygame 269
Installing Python Packages with pip 270
Installing Pygame on Linux 271
Installing Pygame on OS X 272
Installing Pygame on Windows 273
Starting the Game Project 273
Creating a Pygame Window and Responding to User Input 274
Setting the Background Color 275
Creating a Settings Class 276
Adding the Ship Image 277
Creating the Ship Class 278
Drawing the Ship to the Screen 279
Refactoring: the game_functions Module 280
The check_events() Function 280
The update_screen() Function 281
Exercise 12-1: Blue Sky 282
Exercise 12-2: Game Character 282
Piloting the Ship 282
Responding to a Keypress 282
Allowing Continuous Movement 283
Moving Both Left and Right 285
Adjusting the Ship's Speed 286
Limiting the Ship's Range 288
Refactoring check_events() 288
A Quick Recap 289
alien_invasion.py 289
settings.py 289
game_functions.py 289
ship.py 290
Exercise 12-3: Rocket 290
Exercise 12-4: Keys 290
Shooting Bullets 290
Adding the Bullet Settings 290
Creating the Bullet Class 291
Storing Bullets in a Group 292
Firing Bullets 293
Deleting Old Bullets 294
Limiting the Number of Bullets 295
Creating the update_bullets() Function 296
Creating the fire_bullet() Function 297
Exercise 12-5: Sideways Shooter 297
Chapter 13: Aliens! 298
Reviewing Your Project 299
Creating the First Alien 299
Creating the Alien Class 300
Creating an Instance of the Alien 301
Making the Alien Appear Onscreen 301
Building the Alien Fleet 302
Determining How Many Aliens Fit in a Row 302
Creating Rows of Aliens 303
Creating the Fleet 304
Refactoring create_fleet() 306
Adding Rows 306
Exercise 13-1: Stars 309
Exercise 13-2: Better Stars 309
Making the Fleet Move 309
Moving the Aliens Right 309
Creating Settings for Fleet Direction 310
Checking to See Whether an Alien Has Hit the Edge 311
Dropping the Fleet and Changing Direction 311
Exercise 13-3: Raindrops 312
Exercise 13-4: Steady Rain 312
Shooting Aliens 313
Detecting Bullet Collisions 313
Making Larger Bullets for Testing 314
Repopulating the Fleet 315
Speeding Up the Bullets 316
Refactoring update_bullets() 316
Exercise 13-5: Catch 317
Ending the Game 317
Detecting Alien-Ship Collisions 317
Responding to Alien-Ship Collisions 318
Aliens that Reach the Bottom of the Screen 321
Game Over! 321
Identifying When Parts of the Game Should Run 322
Exercise 13-6: Game Over 323
Summary 323
Chapter 14: Scoring 324
Adding the Play Button 325
Creating a Button Class 325
Drawing the Button to the Screen 327
Starting the Game 328
Resetting the Game 329
Deactivating the Play Button 330
Hiding the Mouse Cursor 331
Exercise 14-1: Press P to Play 331
Exercise 14-2: Target Practice 331
Leveling Up 332
Modifying the Speed Settings 332
Resetting the Speed 333
Exercise 14-3: Challenging Target Practice 334
Scoring 334
Displaying the Score 334
Making a Scoreboard 336
Updating the Score as Aliens Are Shot Down 337
Making Sure to Score All Hits 338
Increasing Point Values 339
Rounding the Score 340
High Scores 341
Displaying the Level 343
Displaying the Number of Ships 346
Exercise 14-4: All-Time High Score 350
Exercise 14-5: Refactoring 350
Exercise 14-6: Expanding Alien Invasion 350
Summary 350
Project 2: Data Visualization 352
Chapter 15: Generating Data 354
Installing matplotlib 355
On Linux 355
On OS X 355
On Windows 356
Testing matplotlib 356
The matplotlib Gallery 356
Plotting a Simple Line Graph 357
Changing the Label Type and Graph Thickness 357
Correcting the Plot 359
Plotting and Styling Individual Points with scatter() 359
Plotting a Series of Points with scatter() 361
Calculating Data Automatically 361
Removing Outlines from Data Points 362
Defining Custom Colors 363
Using a Colormap 363
Saving Your Plots Automatically 364
Exercise 15-1: Cubes 364
Exercise 15-2: Colored Cubes 364
Random Walks 364
Creating the RandomWalk() Class 365
Choosing Directions 365
Plotting the Random Walk 366
Generating Multiple Random Walks 367
Styling the Walk 368
Coloring the Points 368
Plotting the Starting and Ending Points 369
Cleaning Up the Axes 370
Adding Plot Points 370
Altering the Size to Fill the Screen 371
Exercise 15-3: Molecular Motion 372
Exercise 15-4: Modified Random Walks 372
Exercise 15-5: Refactoring 372
Rolling Dice with Pygal 372
Installing Pygal 373
The Pygal Gallery 373
Creating the Die Class 373
Rolling the Die 374
Analyzing the Results 374
Making a Histogram 375
Rolling Two Dice 376
Rolling Dice of Different Sizes 378
Exercise 15-6: Automatic Labels 379
Exercise 15-7: Two D8s 379
Exercise 15-8: Three Dice 379
Exercise 15-9: Multiplication 379
Exercise 15-10: Practicing with Both Libraries 379
Summary 380
Chapter 16: Downloading Data 382
The CSV File Format 383
Parsing the CSV File Headers 383
Printing the Headers and Their Positions 384
Extracting and Reading Data 385
Plotting Data in a Temperature Chart 386
The datetime Module 387
Plotting Dates 388
Plotting a Longer Timeframe 389
Plotting a Second Data Series 390
Shading an Area in the Chart 391
Error-Checking 392
Exercise 16-1: San Francisco 395
Exercise 16-2: Sitka-Death Valley Comparison 395
Exercise 16-3: Rainfall 395
Exercise 16-4: Explore 395
Mapping Global Data Sets: JSON Format 395
Downloading World Population Data 395
Extracting Relevant Data 396
Converting Strings into Numerical Values 397
Obtaining Two-Digit Country Codes 398
Building a World Map 400
Plotting Numerical Data on a World Map 401
Plotting a Complete Population Map 402
Grouping Countries by Population 404
Styling World Maps in Pygal 405
Lightening the Color Theme 407
Exercise 16-5: All Countries 408
Exercise 16-6: Gross Domestic Product 408
Exercise 16-7: Choose Your Own Data 408
Exercise 16-8: Testing the country_codes Module 408
Summary 408
Chapter 17: Working with APIs 410
Using a Web API 411
Git and GitHub 411
Requesting Data Using an API Call 411
Installing Requests 412
Processing an API Response 412
Working with the Response Dictionary 413
Summarizing the Top Repositories 415
Monitoring API Rate Limits 416
Visualizing Repositories Using Pygal 417
Refining Pygal Charts 419
Adding Custom Tooltips 420
Plotting the Data 421
Adding Clickable Links to Our Graph 423
The Hacker News API 423
Exercise 17-1: Other Languages 426
Exercise 17-2: Active Discussions 426
Exercise 17-3: Testing python_repos.py 426
Summary 426
Project 3: Web Applications 428
Chapter 18: Getting Started with Django 430
Setting Up a Project 431
Writing a Spec 431
Creating a Virtual Environment 431
Installing virtualenv 432
Activating the Virtual Environment 432
Installing Django 433
Creating a Project in Django 433
Creating the Database 434
Viewing the Project 434
Exercise 18-1: New Projects 435
Starting an App 436
Defining Models 436
Activating Models 437
The Django Admin Site 439
Defining the Entry Model 441
Migrating the Entry Model 442
Registering Entry with the Admin Site 442
The Django Shell 443
Exercise 18-2: Short Entries 445
Exercise 18-3: The Django API 445
Exercise 18-4: Pizzeria 445
Making Pages: The Learning Log Home Page 445
Mapping an URL 446
Writing a View 447
Writing a Template 448
Exercise 18-5: Meal Planner 449
Exercise 18-6: Pizzeria Home Page 449
Building Additional Pages 449
Template Inheritance 449
The Topics Page 451
Individual Topic Pages 454
Exercise 18-7: Template Documentation 457
Exercise 18-8: Pizzeria Pages 457
Summary 458
Chapter 19: User Accounts 460
Allowing Users to Enter Data 461
Adding New Topics 461
Adding New Entries 465
Editing Entries 468
Exercise 19-1: Blog 471
Setting Up User Accounts 472
The users App 472
The Login Page 473
Logging Out 475
The Registration Page 476
Exercise 19-2: Blog Accounts 479
Allowing Users to Own Their Data 479
Restricting Access with @login_required 480
Connecting Data to Certain Users 481
Restricting Topics Access to Appropriate Users 484
Protecting a User's Topics 484
Protecting the edit_entry Page 485
Associating New Topics with the Current User 486
Exercise 19-3: Refactoring 487
Exercise 19-4: Protecting new_entry 487
Exercise 19-5: Protected Blog 487
Summary 487
Chapter 20: Styling and Deploying an App 488
Styling Learning Log 489
The django-bootstrap3 App 489
Using Bootstrap to Style Learning Log 490
Modifying base.html 491
Styling the Home Page Using a Jumbotron 494
Styling the Login Page 494
Styling the new_topic Page 496
Styling the Topics Page 496
Styling the Entries on the Topic Page 497
Exercise 20-1: Other Forms 499
Exercise 20-2: Stylish Blog 499
Deploying Learning Log 499
Making a Heroku Account 499
Installing the Heroku Toolbelt 499
Installing Required Packages 499
Creating a Packages List with a requirements.txt File 500
Specifying the Python Runtime 501
Modifying settings.py for Heroku 501
Making a Procfile to Start Processes 502
Modifying wsgi.py for Heroku 503
Making a Directory for Static Files 503
Using the gunicorn Server Locally 503
Using Git to Track the Project's Files 504
Pushing to Heroku 506
Setting Up the Database on Heroku 507
Refining the Heroku Deployment 508
Securing the Live Project 509
Committing and Pushing Changes 510
Creating Custom Error Pages 511
Ongoing Development 513
The SECRET_KEY Setting 514
Deleting a Project on Heroku 514
Exercise 20-3: Live Blog 515
Exercise 20-4: More 404s 515
Exercise 20-5: Extended Learning Log 515
Summary 515
Afterword 516
Appendix A: Installing Python 518
Python on Linux 518
Finding the Installed Version 519
Installing Python 3 on Linux 519
Python on OS X 519
Finding the Installed Version 519
Using Homebrew to Install Python 3 520
Python on Windows 521
Installing Python 3 on Windows 521
Finding the Python Interpreter 521
Adding Python to Your Path Variable 522
Python Keywords and Built-in Functions 522
Python Keywords 522
Python Built-in Functions 523
Appendix B: Text Editors 524
Geany 525
Installing Geany on Linux 525
Installing Geany on Windows 525
Running Python Programs in Geany 526
Customizing Geany Settings 526
Sublime Text 527
Installing Sublime Text on OS X 527
Installing Sublime Text on Linux 527
Installing Sublime Text on Windows 528
Running Python Programs in Sublime Text 528
Configuring Sublime Text 528
Customizing Sublime Text Settings 529
IDLE 529
Installing IDLE on Linux 529
Installing IDLE on OS X 529
Installing IDLE on Windows 530
Customizing IDLE Settings 530
Emacs and vim 530
Appendix C: Getting Help 532
First Steps 532
Try It Again 533
Take a Break 533
Refer to This Book's Resources 533
Searching Online 534
Stack Overflow 534
The Official Python Documentation 534
Official Library Documentation 535
r/learnpython 535
Blog Posts 535
IRC (Internet Relay Chat) 535
Make an IRC Account 535
Channels to Join 536
IRC Culture 536
Appendix D: Using Git for Version Control 538
Installing Git 539
Installing Git on Linux 539
Installing Git on OS X 539
Installing Git on Windows 539
Configuring Git 539
Making a Project 540
Ignoring Files 540
Initializing a Repository 540
Checking the Status 541
Adding Files to the Repository 541
Making a Commit 542
Checking the Log 542
The Second Commit 543
Reverting a Change 544
Checking Out Previous Commits 545
Deleting the Repository 546
Index 548
Resources 561
Alternative description
Python Crash Course is a fast-paced, thorough introduction to Python that will have you writing programs, solving problems, and making things that work in no time.In the first half of the book, you'll learn about basic programming concepts, such as lists, dictionaries, classes, and loops, and practice writing clean and readable code with exercises for each topic. You'll also learn how to make your programs interactive and how to test your code safely before adding it to a project. In the second half of the book, you'll put your new knowledge into practice with three substantial projects: a Space Invaders–inspired arcade game, data visualizations with Python's super-handy libraries, and a simple web app you can deploy online.As you work through Python Crash Course you'll learn how to:–Use powerful Python libraries and tools, including matplotlib, NumPy, and Pygal–Make 2D games that respond to keypresses and mouse clicks, and that grow more difficult as the game progresses–Work with data to generate interactive visualizations–Create and customize Web apps and deploy them safely online–Deal with mistakes and errors so you can solve your own programming problemsIf you've been thinking seriously about digging into programming, Python Crash Course will get you up to speed and have you writing real programs fast. Why wait any longer? Start your engines and code!Uses Python 2 and 3
Alternative description
"A project-based introduction to programming in Python, with exercises. Covers general programming concepts, Python fundamentals, and problem solving. Includes three projects - how to create a simple video game, use data visualization techniques to make graphs and charts, and build an interactive web application"-- Provided by publisher
date open sourced
2016-01-03
Read more…

🐢 Slow downloads

From trusted partners. More information in the FAQ. (might require browser verification — unlimited downloads!)

All download options have the same file, and should be safe to use. That said, always be cautious when downloading files from the internet, especially from sites external to Anna’s Archive. For example, be sure to keep your devices updated.
  • For large files, we recommend using a download manager to prevent interruptions.
    Recommended download managers: Motrix
  • You will need an ebook or PDF reader to open the file, depending on the file format.
    Recommended ebook readers: Anna’s Archive online viewer, ReadEra, and Calibre
  • Use online tools to convert between formats.
    Recommended conversion tools: CloudConvert and PrintFriendly
  • You can send both PDF and EPUB files to your Kindle or Kobo eReader.
    Recommended tools: Amazon‘s “Send to Kindle” and djazz‘s “Send to Kobo/Kindle”
  • Support authors and libraries
    ✍️ If you like this and can afford it, consider buying the original, or supporting the authors directly.
    📚 If this is available at your local library, consider borrowing it for free there.