<p>Preface xix</p> <p><strong>Module 1: Getting Started in Python 1</strong></p> <p><strong>Exercise 0: Gearing Up 2</strong><br>General Instructions 2<br>Minimalist Start 3<br>Complete Instructions 3<br>Testing Your Setup 3<br>Learning the Command Line 4<br>Next Steps 5</p> <p><strong>Exercise 1: A Good First Program 6</strong><br>What You Should See 7<br>Study Drills 8<br>Common Student Questions 9<br>The Blue Plus 9</p> <p><strong>Exercise 2: Comments and Pound Characters 10</strong><br>What You Should See 10<br>Study Drills 10<br>Common Student Questions 11</p> <p><strong>Exercise 3: Numbers and Math 12</strong><br>What You Should See 13<br>Study Drills 13<br>Common Student Questions 13</p> <p><strong>Exercise 4: Variables and Names 16</strong><br>What You Should See 17<br>Study Drills 17<br>Common Student Questions 17</p> <p><strong>Exercise 5: More Variables and Printing 20</strong><br>What You Should See 20<br>Study Drills 21<br>Common Student Questions 21</p> <p><strong>Exercise 6: Strings and Text 22</strong><br>What You Should See 23<br>Study Drills 23<br>Break It 23<br>Common Student Questions 24</p> <p><strong>Exercise 7: Combining Strings 26</strong><br>What You Should See 26<br>Study Drills 26<br>Break It 27<br>Common Student Questions 27</p> <p><strong>Exercise 8: Formatting Strings Manually 28</strong><br>What You Should See 28<br>Study Drills 29<br>Common Student Questions 29</p> <p><strong>Exercise 9: Multi-Line Strings 30</strong><br>What You Should See 30<br>Study Drills 31<br>Common Student Questions 31</p> <p><strong>Exercise 10: Escape Codes in Strings 32</strong><br>What You Should See 33<br>Escape Sequences 33<br>Study Drills 34<br>Common Student Questions 34</p> <p><strong>Exercise 11: Asking People Questions 36</strong><br>What You Should See 36<br>Study Drills 37<br>Common Student Questions 37</p> <p><strong>Exercise 12: An Easier Way to Prompt 38</strong><br>What You Should See 38<br>Study Drills 38<br>Common Student Questions 39</p> <p><strong>Exercise 13: Parameters, Unpacking, Variables 40</strong><br>Code Description 41<br>Hold Up! Features Have Another Name 42<br>What You Should See 42<br>Study Drills 43<br>Common Student Questions 43</p> <p><strong>Exercise 14: Prompting and Passing 46</strong><br>What You Should See 47<br>Study Drills 47<br>Common Student Questions 47</p> <p><strong>Exercise 15: Reading Files 50</strong><br>What You Should See 51<br>Study Drills 51<br>Common Student Questions 52</p> <p><strong>Exercise 16: Reading and Writing Files 54</strong><br>What You Should See 55<br>Study Drills 55<br>Common Student Questions 56</p> <p><strong>Exercise 17: More Files 58</strong><br>What You Should See 59<br>Study Drills 59<br>Common Student Questions 59</p> <p><strong>Module 2: The Basics of Programming 61</strong></p> <p><strong>Exercise 18: Names, Variables, Code, Functions 62</strong><br>Exercise Code 63<br>What You Should See 65<br>Study Drills 65<br>Common Student Questions 66</p> <p><strong>Exercise 19: Functions and Variables 68</strong><br>What You Should See 69<br>Study Drills 70<br>Common Student Questions 70</p> <p><strong>Exercise 20: Functions and Files 72</strong><br>What You Should See 73<br>Study Drills 73<br>Common Student Questions 74</p> <p><strong>Exercise 21: Functions Can Return Something 76</strong><br>What You Should See 77<br>Study Drills 77<br>Common Student Questions 78</p> <p><strong>Exercise 22: Strings, Bytes, and Character Encodings 80</strong><br>Initial Research 80<br>Switches, Conventions, and Encodings 82<br>Dissecting the Output 84<br>Dissecting the Code 84<br>Encodings Deep Dive 86<br>Breaking It 87</p> <p><strong>Exercise 23: Introductory Lists 88</strong><br>Accessing Elements of a List 88<br>Practicing Lists 89<br>The Code 89<br>The Challenge 90<br>Final Challenge 91</p> <p><strong>Exercise 24: Introductory Dictionaries 92</strong><br>Key/Value Structures 92<br>Combining Lists with Data Objects 93<br>The Code 94<br>What You Should See 95<br>The Challenge 95<br>Final Challenge 96</p> <p><strong>Exercise 25: Dictionaries and Functions 98</strong><br>Step 1: Function Names Are Variables 98<br>Step 2: Dictionaries with Variables 98<br>Step 3: Dictionaries with Functions 99<br>Step 4: Deciphering the Last Line 99<br>Study Drill 100</p> <p><strong>Exercise 26: Dictionaries and Modules 102</strong><br>Step 1: Review of import 102<br>Step 2: Find the __dict__ 102<br>Step 3: Change the __dict__ 103<br>Study Drill: Find the "Dunders" 104</p> <p><strong>Exercise 27: The Five Simple Rules to the Game of Code 106</strong><br>Rule 1: Everything Is a Sequence of Instructions 106<br>Rule 2: Jumps Make the Sequence Non-Linear 108<br>Rule 3: Tests Control Jumps 110<br>Rule 4: Storage Controls Tests 111<br>Rule 5: Input/Output Controls Storage 112<br>Putting It All Together 113</p> <p><strong>Exercise 28: Memorizing Logic 116</strong><br>The Truth Terms 116<br>The Truth Tables 117<br>Common Student Questions 119</p> <p><strong>Exercise 29: Boolean Practice 120</strong><br>What You Should See 122<br>Study Drills 122<br>Common Student Questions 122</p> <p><strong>Exercise 30: What If 124</strong><br>What You Should See 124<br>dis() It 125<br>Study Drill 125<br>Common Student Questions 125</p> <p><strong>Exercise 31: Else and If 126</strong><br>What You Should See 127<br>dis() It 127<br>Study Drills 128<br>Common Student Questions 128</p> <p><strong>Exercise 32: Making Decisions 130</strong><br>What You Should See 131<br>dis() It 131<br>Study Drills 132<br>Common Student Questions 132</p> <p><strong>Exercise 33: Loops and Lists 134</strong><br>What You Should See 135<br>dis() It 136<br>Study Drills 137<br>Common Student Questions 137</p> <p><strong>Exercise 34: While Loops 138</strong><br>What You Should See 139<br>dis() It 139<br>Study Drills 140<br>Common Student Questions 140</p> <p><strong>Exercise 35: Branches and Functions 142</strong><br>What You Should See 143<br>Study Drills 144<br>Common Student Questions 144</p> <p><strong>Exercise 36: Designing and Debugging 146</strong><br>From Idea to Working Code 146<br>Rules for If-Statements 149<br>Rules for Loops 149<br>Tips for Debugging 149<br>Homework 150</p> <p><strong>Exercise 37: Symbol Review 152</strong><br>Keywords 152<br>Data Types 153<br>String Escape Sequences 154<br>Old-Style String Formats 154<br>Operators 155<br>Reading Code 156<br>Study Drills 157<br>Common Student Questions 157</p> <p><strong>Module 3: Applying What You Know 159</strong></p> <p><strong>Exercise 38: Beyond Jupyter for Windows 160</strong><br>Why Learn PowerShell? 161<br>What Is PowerShell? 161<br>Crash Landing 171</p> <p><strong>Exercise 39: Beyond Jupyter for macOS/Linux 172</strong><br>Why Learn Bash or ZSH? 173<br>What Is Bash? 173<br>Crash Landing 184</p> <p><strong>Exercise 40: Advanced Developer Tools 186</strong><br>Managing conda Environments 186<br>Adding conda-forge 187<br>Using pip 188<br>Using a .condarc 188<br>General Editing Tips 189<br>Going Further 189</p> <p><strong>Exercise 41: A Project Skeleton 190</strong><br>Activate an Environment 190<br>Just Use cookiecutter 190<br>Building Your Project 191<br>Installing Your Project 191<br>Testing the Install 192<br>Remove test-project 192<br>Common Errors 193<br>Study Drills 193</p> <p><strong>Exercise 42: Doing Things to Lists 194</strong><br>What You Should See 195<br>What Lists Can Do 196<br>When to Use Lists 197<br>Study Drills 197<br>Common Student Questions 198</p> <p><strong>Exercise 43: Doing Things to Dictionaries 200</strong><br>A Dictionary Example 201<br>What You Should See 203<br>What Dictionaries Can Do 203<br>Study Drills 204<br>Common Student Questions 204</p> <p><strong>Exercise 44: From Dictionaries to Objects 206</strong><br>Step 1: Passing a Dict to a Function 206<br>Step 2: talk inside the Dict 207<br>Step 3: Closures 208<br>Step 4: A Person Constructor 209<br>Study Drills 211</p> <p><strong>Exercise 45: Basic Object-Oriented Programming 212</strong><br>Python's People 212<br>Using dir() and __dict__ 213<br>About the Dot (.) 214<br>Terminology 215<br>A Word on self 216<br>Study Drills 217<br>Common Student Questions 217</p> <p><strong>Exercise 46: Inheritance and Advanced OOP 218</strong><br>How This Looks in Code 219<br>About class Name(object) 221<br>Study Drills 221<br>Common Student Questions 222</p> <p><strong>Exercise 47: Basic Object-Oriented Analysis and Design 224</strong><br>The Analysis of a Simple Game Engine 225<br>Top Down versus Bottom Up 229<br>The Code for "Gothons from Planet Percal #25" 230<br>What You Should See 236<br>Study Drills 237<br>Common Student Questions 237</p> <p><strong>Exercise 48: Inheritance versus Composition 238</strong><br>What Is Inheritance? 238<br>The Reason for super() 243<br>Composition 243<br>When to Use Inheritance or Composition 245<br>Study Drill 245<br>Common Student Questions 246</p> <p><strong>Exercise 49: You Make a Game 248</strong><br>Evaluating Your Game 248<br>Function Style 249<br>Class Style 249<br>Code Style 250<br>Good Comments 250<br>Evaluate Your Game 250</p> <p><strong>Exercise 50: Automated Testing 252</strong><br>What Is the Purpose of Testing? 252<br>How to Test Efficiently 252<br>Install PyTest 253<br>Simple PyTest Demo 254<br>Running pytest 255<br>Exceptions and try/except 255<br>Getting Coverage Reports 256<br>Study Drills 256<br>Common Student Questions 257</p> <p><strong>Module 4: Python and Data Science 259</strong></p> <p><strong>Exercise 51: What Is Data Munging? 260</strong><br>Why Data Munging? 261<br>The Problem 261<br>The Setup 262<br>How to Code 262<br>Process Example 263<br>Solution Strategies 265<br>Awesome ETL Tools 266<br>Study Drills 266</p> <p><strong>Exercise 52: Scraping Data from the Web 268</strong><br>Introducing with 268<br>The Problem 269<br>The Setup 269<br>The Clue 270<br>Awesome Scraping Tools 270<br>Study Drills 271</p> <p><strong>Exercise 53: Getting Data from APIs 272</strong><br>Introducing JSON 272<br>The Problem 273<br>The Setup 274<br>The Clue 274<br>Awesome API Tools 275<br>Study Drills 275</p> <p><strong>Exercise 54: Data Conversion with pandas 276</strong><br>Introducing Pandoc 276<br>The Problem 276<br>The Setup 277<br>The Clue 277<br>Study Drills 278</p> <p><strong>Exercise 55: How to Read Documentation (Featuring pandas) 280</strong><br>Why Programmer Documentation Sucks 280<br>How to Actively Read Programmer Docs 281<br>Step #1: Find the Docs 281<br>Step #2: Determine Your Strategy 282<br>Step #3: Code First, Docs Second 283<br>Step #4: Break or Change the Code 283<br>Step #5: Take Notes 284<br>Step #6: Use It on Your Own 284<br>Step #7: Write About What You Learned 284<br>Step #8: What’s the Gestalt? 285<br>Reading My pandas Curriculum 286</p> <p><strong>Exercise 56: Using Only pandas 288</strong><br>Make a Project 288<br>The Problem 288<br>The Setup 289<br>Study Drill 289</p> <p><strong>Exercise 57: The SQL Crash Course 290</strong><br>What Is SQL? 290<br>The Setup 291<br>Fixing and Loading 292<br>Create, Read, Update, Delete 293<br>SELECT 293<br>Date and Time 294<br>INSERT 295<br>UPDATE 296<br>DELETE and Transactions 297<br>Math, Aggregates, and GROUP BY 298<br>Python Access 299</p> <p><strong>Exercise 58: SQL Normalization 300</strong><br>What Is Normalization? 300<br>First Normal Form 301<br>Second Normal Form (2NF) 303<br>Querying 2NF Data 306<br>Querying with Joins 308<br>Study Drills 308</p> <p><strong>Exercise 59: SQL Relationships 310</strong><br>One-to-Many (1:M) 310<br>Many-to-Many (M:M) 311<br>One-to-One (1:1) 312<br>Attributed Relations 313<br>Querying M:M Tables 313<br>Your Last Study Drill 314</p> <p><strong>Exercise 60: Advice from an Even Older Programmer 316</strong></p> <p>Index 318</p>