Python Getting Started Essential Books: Python Programming: From Getting Started to Practice

Posted by brettpower on Sun, 16 Jan 2022 18:25:53 +0100

Book Information

Python programming: from getting started to practice

  • Title: Python Programming: From Getting Started to Practice
  • Original name: Python Crash Course
  • Author: [US] Eric Matthews
  • Douban score: 9.1 (2534 people evaluated)

content validity

  • This book is a Python introductory book for Python readers at all levels. The book is divided into two parts: The first part introduces the basic concepts that you must understand when programming with Python, including the introduction of powerful Python libraries and tools such as matplotlib, NumPy and Pygal, as well as lists, dictionaries, if statements, classes, files and exceptions, code tests, and so on. The second part puts theory into practice and explains how to develop three projects, including how simple Python 2D game development can use data to generate interactive infographics, create and customize simple Web applications, and help readers solve common programming problems and confusions.

Introduction to the Author

  • Eric Matthes, a high school science and math teacher, lives in Alaska and teaches Python introductory courses locally. He has been writing programs since he was 5 years old.

Catalog

Part One Fundamentals
 Chapter 1 start  2
1.1 Set up programming environment  2
1.1.1 Python 2 and Python 3  2
1.1.2 Function Python code snippet  3
1.1.3 Hello World program  3
1.2 Build in different operating systems Python Programming environment  3
1.2.1 stay Linux System Setup Python Programming environment  3
1.2.2 stay OS X System Setup Python Programming environment  6
1.2.3 stay Windows System Setup Python Programming environment  8
1.3 Solve installation problems  12
1.4 Run from terminal Python program  13
1.4.1 stay Linux and OS X System runs from terminal Python program  13
1.4.2 stay Windows System runs from terminal Python program  13
1.5 Summary  14
 Chapter 2 Variables and simple data types  15
2.1 Function hello_world.py What happens when  15
2.2 variable  16
2.2.1 Naming and use of variables  16
2.2.2 Avoid naming errors when using variables  17
2.3 Character string  18
2.3.1 Use methods to modify the case of strings  19
2.3.2 Merge (stitch) strings  19
2.3.3 Use tabs or line breaks to add white space  20
2.3.4 Delete blanks  21
2.3.5 Avoid syntax errors when using strings  22
2.3.6 Python 2 In print Sentence  23
2.4 number  24
2.4.1 integer  24
2.4.2 Floating point number  25
2.4.3 Using functions str()Avoid type errors  25
2.4.4 Python 2 Integer in  26
2.5 Notes  27
2.5.1 How to write notes  27
2.5.2 What kind of notes should I write  28
2.6 Python Zen  28
2.7 Summary  30
 Chapter 3 Introduction to Lists  31
3.1 What is a list  31
3.1.1 Access list elements  32
3.1.2 Index starts at 0 instead of 1  32
3.1.3 Use each value in the list  33
3.2 Modify, add, and delete elements  33
3.2.1 Modify List Elements  34
3.2.2 Add elements to the list  34
3.2.3 Remove elements from list  35
3.3 Organization List  39
3.3.1 Usage method sort()Permanently sort lists  39
3.3.2 Using functions sorted()Temporarily sort the list  40
3.3.3 Print list upside down  41
3.3.4 Determine the length of the list  41
3.4 Avoid index errors when using lists  42
3.5 Summary  43
 Chapter 4 Action List  44
4.1 Traverse the entire list  44
4.1.1 Deep study of cycles  45
4.1.2 stay for Do more in a loop  46
4.1.3 stay for Do something after the loop ends  47
4.2 Avoid indentation errors  47
4.2.1 Forget Indentation  48
4.2.2 Forgot to indent extra lines of code  48
4.2.3 Unnecessary indentation  49
4.2.4 Unnecessary indentation after loop  49
4.2.5 A colon was omitted  50
4.3 Create a list of values  51
4.3.1 Using functions range()  51
4.3.2 Use range()Create Number List  51
4.3.3 Perform simple statistical calculations on a list of numbers  53
4.3.4 List Resolution  53
4.4 Use a part of the list  54
4.4.1 Section  54
4.4.2 Traversing slices  56
4.4.3 Copy List  56
4.5 tuple  59
4.5.1 Define tuples  59
4.5.2 Traversing through all values in a tuple  59
4.5.3 Modify tuple variable  60
4.6 Format Code  61
4.6.1 Formatting Guide  61
4.6.2 indent  61
4.6.3 president  61
4.6.4 Blank Line  62
4.6.5 Other Formatting Guidelines  62
4.7 Summary  63
 Chapter 5 if Sentence  64
5.1 A simple example  64
5.2 Conditional Test  65
5.2.1 Check equality  65
5.2.2 Do not consider case when checking equality  65
5.2.3 Check for inequality  66
5.2.4 Compare Numbers  67
5.2.5 Check multiple conditions  67
5.2.6 Check if a specific value is included in the list  68
5.2.7 Check if a specific value is not included in the list  69
5.2.8 Boolean expression  69
5.3 if Sentence  70
5.3.1 Ordinary if Sentence  70
5.3.2 if-else Sentence  71
5.3.3 if-elif-else structure  72
5.3.4 Use multiple elif code block  73
5.3.5 ellipsis else code block  74
5.3.6 Testing multiple conditions  74
5.4 Use if Statement Processing List  76
5.4.1 Check for special elements  77
5.4.2 Make sure the list is not empty  78
5.4.3 Use multiple lists  78
5.5 Set up if Format of statement  80
5.6 Summary  80
 Chapter 6 Dictionaries  81
6.1 A simple dictionary  81
6.2 Using a dictionary  82
6.2.1 Accessing values in a dictionary  82
6.2.2 Add Key-Value Pair  83
6.2.3 Create an empty dictionary first  83
6.2.4 Modify values in the dictionary  84
6.2.5 Delete Key-Value Pair  85
6.2.6 A Dictionary of similar objects  86
6.3 Traverse Dictionary  87
6.3.1 Traverse through all key-value pairs  87
6.3.2 Traverse all keys in a dictionary  89
6.3.3 Walk through all keys in the dictionary in order  91
6.3.4 Traverse through all values in the dictionary  91
6.4 nesting  93
6.4.1 Dictionary List  93
6.4.2 Store lists in a dictionary  95
6.4.3 Store a dictionary in a dictionary  97
6.5 Summary  99
 Chapter 7 User input and while loop  100
7.1 function input()How it works  100
7.1.1 Write clear programs  101
7.1.2 Use int()To get a numeric input  102
7.1.3 Modulo operator  103
7.1.4 stay Python 2.7 Get input in  104
7.2 while Introduction to Cycle  104
7.2.1 Use while loop  104
7.2.2 Let users choose when to exit  105
7.2.3 Use logo  106
7.2.4 Use break Exit Loop  107
7.2.5 Use in loop continue  108
7.2.6 Avoid infinite loops  109
7.3 Use while Loop through lists and dictionaries  110
7.3.1 Move elements between lists  110
7.3.2 Delete all list elements that contain a specific value  111
7.3.3 Use user input to populate the dictionary  112
7.4 Summary  113
 Chapter 8 function  114
8.1 Define Functions  114
8.1.1 Transfer information to a function  115
8.1.2 Arguments and Formal Parameters  115
8.2 Pass-through argument  116
8.2.1 Positional arguments  116
8.2.2 Key Arguments  118
8.2.3 Default value  118
8.2.4 Equivalent function call  119
8.2.5 Avoid argument errors  120
8.3 Return value  121
8.3.1 Return a simple value  121
8.3.2 Make arguments optional  122
8.3.3 Return to Dictionary  123
8.3.4 Combining functions with while loop  124
8.4 Delivery List  126
8.4.1 Modify List in Function  126
8.4.2 Disable function modification list  129
8.5 Pass any number of arguments  130
8.5.1 Combining positional and any number of arguments  131
8.5.2 Use any number of keyword arguments  131
8.6 Store functions in modules  133
8.6.1 Import entire module  133
8.6.2 Import specific functions  134
8.6.3 Use as Alias a function  134
8.6.4 Use as Assign an alias to a module  135
8.6.5 Import all functions in a module  135
8.7 Function Writing Guide  136
8.8 Summary  137
 Chapter 9 class  138
9.1 Create and use classes  138
9.1.1 Establish Dog class  139
9.1.2 Create instances from classes  140
9.2 Using classes and instances  142
9.2.1 Car class  143
9.2.2 Specify default values for attributes  143
9.2.3 Modify the value of an attribute  144
9.3 inherit  147
9.3.1 Methods of subclasses__init__()  147
9.3.2 Python 2.7 Inheritance in  149
9.3.3 Define properties and methods for subclasses  149
9.3.4 Method to override parent class  150
9.3.5 Use instances as attributes  150
9.3.6 Simulate physical objects  152
9.4 Import Class  153
9.4.1 Import a single class  153
9.4.2 Storing multiple classes in one module  155
9.4.3 Import multiple classes from a module  156
9.4.4 Import entire module  157
9.4.5 Import all classes in a module  157
9.4.6 Import another module in one module  157
9.4.7 Customize Workflow  158
9.5 Python Standard Library  159
9.6 Class Coding Style  161
9.7 Summary  161
 Chapter 10 Files and exceptions  162
10.1 Read data from a file  162
10.1.1 Read the entire file  162
10.1.2 File Path  164
10.1.3 Read line by line  165
10.1.4 Create a list of lines of a file  166
10.1.5 Use the contents of the file  166
10.1.6 Large files containing one million bits  168
10.1.7 Does the circumference value include your birthday  168
10.2 write file  169
10.2.1 Write empty file  170
10.2.2 Write multiple lines  170
10.2.3 Attach to File  171
10.3 abnormal  172
10.3.1 Handle ZeroDivisionError abnormal  172
10.3.2 Use try-except code block  173
10.3.3 Use exceptions to avoid crashes  173
10.3.4 else code block  174
10.3.5 Handle FileNotFoundError abnormal  175
10.3.6 Analyzing Text  176
10.3.7 Use multiple files  177
10.3.8 Silence on failure  178
10.3.9 Decide which errors to report  179
10.4 Store data  180
10.4.1 Use json.dump()and json.load()  180
10.4.2 Save and read user-generated data  181
10.4.3 Restructure  183
10.5 Summary  186
 Chapter 11 Test Code  187
11.1 Test function  187
11.1.1 Unit tests and test cases  188
11.1.2 Passable Tests  188
11.1.3 Failed Tests  190
11.1.4 What to do if the test fails  191
11.1.5 Add a new test  191
11.2 Test Class  193
11.2.1 Various assertion methods  193
11.2.2 A class to test  194
11.2.3 test AnonymousSurvey class  195
11.2.4 Method setUp()  197
11.3 Summary  199
 Part Two Project
 Project 1 Alien Invasion  202
 Chapter 12 Armed Ships  203
12.1 Planning Project  203
12.2 install Pygame  204
12.2.1 Use pip install Python package  204
12.2.2 stay Linux System Installation Pygame  206
12.2.3 stay OS X System Installation Pygame  207
12.2.4 stay Windows System Installation Pygame  207
12.3 Start Game Item  207
12.3.1 Establish Pygame Window and response to user input  208
12.3.2 Set Background Color  209
12.3.3 Create Settings Class  210
12.4 Add ship image  211
12.4.1 Establish Ship class  212
12.4.2 Draw the ship on the screen  213
12.5 Refactoring: Modules game_functions  214
12.5.1 function check_events()  214
12.5.2 function update_screen()  215
12.6 Driving a Spacecraft  216
12.6.1 Response key  216
12.6.2 Allow constant movement  217
12.6.3 Move left and right  219
12.6.4 Adjust the speed of the ship  220
12.6.5 Limit the range of motion of a spaceship  221
12.6.6 Restructure check_events()  222
12.7 A brief review  223
12.7.1 alien_invasion.py  223
12.7.2 settings.py  223
12.7.3 game_functions.py  223
12.7.4 ship.py  223
12.8 Shooting  224
12.8.1 Add Bullet Settings  224
12.8.2 Establish Bullet class  224
12.8.3 Store bullets in a marshal  226
12.8.4 FireStarter  227
12.8.5 Remove lost bullets  228
12.8.6 Limit the number of bullets  229
12.8.7 Create function update_bullets()  229
12.8.8 Create function fire_bullet()  230
12.9 Summary  231
 Chapter 13 Alien  232
13.1 Retrospective Project  232
13.2 Create the First Alien  233
13.2.1 Establish Alien class  233
13.2.2 Establish Alien Example  234
13.2.3 Let aliens appear on the screen  235
13.3 Create a group of Aliens  236
13.3.1 Determine how many aliens a row can hold  236
13.3.2 Create MultiPlanet Aliens  236
13.3.3 Create an Alien Population  237
13.3.4 Restructure create_fleet()  239
13.3.5 add rows  240
13.4 Move Alien Populations  242
13.4.1 Move Alien Right  243
13.4.2 Create settings that represent the direction of aliens'movement  244
13.4.3 Check if aliens hit the edge of the screen  244
13.4.4 Move the aliens down and change direction  245
13.5 Kill Aliens  246
13.5.1 Detecting collisions between bullets and aliens  246
13.5.2 Create big bullets for testing  247
13.5.3 Generating new aliens  248
13.5.4 Increase the speed of the bullet  249
13.5.5 Restructure update_bullets()  249
13.6 End Game  250
13.6.1 Detecting collisions between aliens and spacecraft  250
13.6.2 Response to Alien and Spacecraft Collisions  251
13.6.3 Aliens reach the bottom of the screen  254
13.6.4 Game over  255
13.7 Determine which parts of the game should be run  255
13.8 Summary  256
 Chapter 14 Scoring  257
14.1 Add to Play Button  257
14.1.1 Establish Button class  258
14.1.2 Draw buttons on screen  259
14.1.3 Start the game  261
14.1.4 Reset  261
14.1.5 take Play Button switches to inactive state  263
14.1.6 hide cursor  263
14.2 Increase Level  264
14.2.1 Modify speed settings  264
14.2.2 Reset Velocities  266
14.3 Scoring  267
14.3.1 Show Score  267
14.3.2 Create scoreboard  268
14.3.3 Update scores when aliens are extinct  270
14.3.4 Include points for each extinct aliens in the score  271
14.3.5 Increase Points  271
14.3.6 Round the score  272
14.3.7 Highest Score  274
14.3.8 Display Level  276
14.3.9 Show the number of ships remaining  279
14.4 Summary  283
 Item 2 Data Visualization  284
 Chapter 15 Generate data  285
15.1 install matplotlib  285
15.1.1 stay Linux System Installation matplotlib  286
15.1.2 stay OS X System Installation matplotlib  286
15.1.3 stay Windows System Installation matplotlib  286
15.1.4 test matplotlib  287
15.1.5 matplotlib Gallery  287
15.2 Draw a simple line chart  287
15.2.1 Modify label text and line thickness  288
15.2.2 Correct Graphics  289
15.2.3 Use scatter()Draw a scatterplot and style it  290
15.2.4 Use scatter()Draw a series of points  291
15.2.5 Automatically calculate data  292
15.2.6 Delete outline of data point  293
15.2.7 Custom Colors  293
15.2.8 Use color mapping  294
15.2.9 Autosave Chart  295
15.3 Random walk  295
15.3.1 Establish RandomWalk()class  296
15.3.2 Select Direction  296
15.3.3 Draw Random Walk Chart  297
15.3.4 Simulate multiple random walks  298
15.3.5 Style Random Walkthrough  299
15.3.6 Coloring dots  299
15.3.7 Redraw start and end points  300
15.3.8 Hide Axis  301
15.3.9 Increase Points  301
15.3.10 Resize to fit screen  302
15.4 Use Pygal Simulate dice roll  303
15.4.1 install Pygal  304
15.4.2 Pygal Gallery  304
15.4.3 Establish Die class  304
15.4.4 Dice roll  305
15.4.5 Analysis results  305
15.4.6 Draw Histogram  306
15.4.7 Roll two dices at the same time  307
15.4.8 Roll two dices with different polygons at the same time  309
15.5 Summary  311
 Chapter 16 Download Data  312
16.1 CSV file format  312
16.1.1 Analysis CSV File Header  313
16.1.2 Print header and its location  314
16.1.3 Extract and read data  314
16.1.4 Draw Temperature Chart  315
16.1.5 Modular datetime  316
16.1.6 Add Date to Chart  317
16.1.7 Cover a longer period of time  318
16.1.8 Draw another data series  319
16.1.9 Coloring Chart Area  320
16.1.10 Error Check  321
16.2 Making world population maps: JSON format  324
16.2.1 Download World Population Data  324
16.2.2 Extracting related data  324
16.2.3 Converts a string to a numeric value  326
16.2.4 Get the two-letter country code  327
16.2.5 Making world maps  329
16.2.6 Presenting digital data on a world map  330
16.2.7 Draw a complete map of the world's population  331
16.2.8 Grouping countries by population  333
16.2.9 Use Pygal Style the world map  334
16.2.10 Highlight color theme  335
16.3 Summary  337
 Chapter 17 Use API  338
17.1 Use Web API  338
17.1.1 Git and GitHub  338
17.1.2 Use API Invoke Request Data  339
17.1.3 install requests  339
17.1.4 Handle API response  340
17.1.5 Processing Response Dictionary  340
17.1.6 Overview of the most popular warehouses  342
17.1.7 Monitor API Rate limit of  343
17.2 Use Pygal Visual warehouse  344
17.2.1 Improvement Pygal Chart  346
17.2.2 Add custom tooltips  347
17.2.3 Drawing from data  349
17.2.4 Add clickable links to the diagram  350
17.3 Hacker News API  350
17.4 Summary  353
 Item 3 Web application program  354
 Chapter 18 Django Introduction  355
18.1 Establish Project  355
18.1.1 Develop specifications  355
18.1.2 Setting up a virtual environment  356
18.1.3 install virtualenv  356
18.1.4 Activate virtual environment  357
18.1.5 install Django  357
18.1.6 stay Django Create project in  357
18.1.7 Create a database  358
18.1.8 View items  359
18.2 Create an application  360
18.2.1 Define Model  360
18.2.2 Activation Model  362
18.2.3 Django Manage Web Sites  363
18.2.4 Define Model Entry  365
18.2.5 Migration Model Entry  366
18.2.6 Register with the administration site Entry  366
18.2.7 Django shell  367
18.3 Create a Web page: Learn Notes Home  369
18.3.1 mapping URL  369
18.3.2 Write Views  371
18.3.3 Writing templates  372
18.4 Create other pages  373
18.4.1 Template Inheritance  373
18.4.2 Pages showing all themes  375
18.4.3 Pages showing a specific theme  378
18.5 Summary  381
 Chapter 19 User account  382
19.1 Enable users to enter data  382
19.1.1 Add a new theme  382
19.1.2 Add a new entry  386
19.1.3 Edit entry  390
19.2 Create user account  392
19.2.1 application program users  393
19.2.2 Logon Page  394
19.2.3 Cancellation  396
19.2.4 Registration Page  397
19.3 Let users own their data  400
19.3.1 Use@login_required Restrict access  400
19.3.2 Associate data with users  402
19.3.3 Allow users to access only their own topics  405
19.3.4 User Protection Theme  405
19.3.5 Protect Page edit_entry  406
19.3.6 Associate the new theme with the current user  406
19.4 Summary  408
 Chapter 20 Style and deploy your application  409
20.1 Style the project Learn Notes  409
20.1.1 application program django-bootstrap3  410
20.1.2 Use Bootstrap To style the project Learn Notes  411
20.1.3 modify base.html  411
20.1.4 Use jumbotron Set the style of the home page  414
20.1.5 Set the style of the login page  415
20.1.6 Set up new_topic Page Style  416
20.1.7 Set up topics Page Style  417
20.1.8 Set up topic Styles for entries on a page  417
20.2 Deploy Learning Notes  419
20.2.1 establish Heroku account  420
20.2.2 install Heroku Toolbelt  420
20.2.3 Install necessary packages  420
20.2.4 Create a file containing a list of packages requirements.txt  421
20.2.5 Appoint Python Edition  422
20.2.6 For deployment to Herohu And modify settings.py  422
20.2.7 Create the startup process Procfile  423
20.2.8 For deployment to Herohu And modify wsgi.py  423
20.2.9 Create a directory to store static files  424
20.2.10 Use locally gunicorn The server  424
20.2.11 Use Git Tracking Project Files  425
20.2.12 Push to Heroku  426
20.2.13 stay Heroku Set up database on  427
20.2.14 Improvement Heroku deploy  428
20.2.15 Ensure project safety  429
20.2.16 Submit and push changes  430
20.2.17 Create a custom error page  431
20.2.18 Continue development  434
20.2.19 Set up SECRET_KEY  434
20.2.20 From project Heroku delete  434
20.3 Summary  435
 appendix A install Python  436
 appendix B text editor  441
 appendix C Ask for help  447
 appendix D Use Git Version control  451
 Postnote  460

This is the end of the article. Thank you for watching, [Python introductory book collection recommendation]( Python Starter Book Collection - Text Collection - Short Book (jianshu.com)
) The next book shares the Python Getting Started Magic Manual

To thank your readers, I would like to share some of my recent collection of programming dries with you, to give back to every reader, and to help you.

The main dry goods are:

(1) Project Source (Forty or fifty interesting and classic hands-on projects and sources)

(2) Videos on Python Basic Introduction, Crawlers, web Development, Big Data Analysis (for learning in Small White)

(3) Python learning roadmap (say goodbye to immersive learning)

4. Live broadcasting rights of two-day Python crawler training camps

All done~Resource dry goods can be found in your profile or obtained by private mail.

Topics: Python Programmer xpdf