<!--[if gte mso 9]><xml> </xml><![endif]--> <p style="margin:0px;"></p> <p style="margin:0px;">Preface xvii</p>Acknowledgments xx <p style="margin:0px;"></p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 0: The Setup 2</p> <p style="margin:0px;">macOS 2</p> <p style="margin:0px;">Windows 3</p> <p style="margin:0px;">Linux 4</p> <p style="margin:0px;">Finding Things on the Internet 5</p> <p style="margin:0px;">Warnings for Beginners 6</p> <p style="margin:0px;">Alternative Text Editors 6</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 1: A Good First Program 8</p> <p style="margin:0px;">What You Should See 10</p> <p style="margin:0px;">Study Drills 12</p> <p style="margin:0px;">Common Student Questions 12</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 2: Comments and Pound Characters 14</p> <p style="margin:0px;">What You Should See 14</p> <p style="margin:0px;">Study Drills 14</p> <p style="margin:0px;">Common Student Questions 15</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 3: Numbers and Math 16</p> <p style="margin:0px;">What You Should See 17</p> <p style="margin:0px;">Study Drills 17</p> <p style="margin:0px;">Common Student Questions 17</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 4: Variables and Names 20</p> <p style="margin:0px;">What You Should See 21</p> <p style="margin:0px;">Study Drills 21</p> <p style="margin:0px;">Common Student Questions 21</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 5: More Variables and Printing 24</p> <p style="margin:0px;">What You Should See 24</p> <p style="margin:0px;">Study Drills 25</p> <p style="margin:0px;">Common Student Questions 25</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 6: Strings and Text 26</p> <p style="margin:0px;">What You Should See 27</p> <p style="margin:0px;">Study Drills 27</p> <p style="margin:0px;">Break It 27</p> <p style="margin:0px;">Common Student Questions 27</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 7: More Printing 28</p> <p style="margin:0px;">What You Should See 28</p> <p style="margin:0px;">Study Drills 29</p> <p style="margin:0px;">Break It 29</p> <p style="margin:0px;">Common Student Questions 29</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 8: Printing, Printing 30</p> <p style="margin:0px;">What You Should See 30</p> <p style="margin:0px;">Study Drills 31</p> <p style="margin:0px;">Common Student Questions 31</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 9: Printing, Printing, Printing 32</p> <p style="margin:0px;">What You Should See 32</p> <p style="margin:0px;">Study Drills 33</p> <p style="margin:0px;">Common Student Questions 33</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 10: What Was That? 34</p> <p style="margin:0px;">What You Should See 35</p> <p style="margin:0px;">Escape Sequences 35</p> <p style="margin:0px;">Study Drills 36</p> <p style="margin:0px;">Common Student Questions 36</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 11: Asking Questions 38</p> <p style="margin:0px;">What You Should See 38</p> <p style="margin:0px;">Study Drills 39</p> <p style="margin:0px;">Common Student Questions 39</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 12: Prompting People 40</p> <p style="margin:0px;">What You Should See 40</p> <p style="margin:0px;">Study Drills 40</p> <p style="margin:0px;">Common Student Questions 41</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 13: Parameters, Unpacking, Variables 42</p> <p style="margin:0px;">Hold Up! Features Have Another Name 42</p> <p style="margin:0px;">What You Should See 43</p> <p style="margin:0px;">Study Drills 44</p> <p style="margin:0px;">Common Student Questions 44</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 14: Prompting and Passing 46</p> <p style="margin:0px;">What You Should See 46</p> <p style="margin:0px;">Study Drills 47</p> <p style="margin:0px;">Common Student Questions 47</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 15: Reading Files 48</p> <p style="margin:0px;">What You Should See 49</p> <p style="margin:0px;">Study Drills 49</p> <p style="margin:0px;">Common Student Questions 50</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 16: Reading and Writing Files 52</p> <p style="margin:0px;">What You Should See 53</p> <p style="margin:0px;">Study Drills 53</p> <p style="margin:0px;">Common Student Questions 54</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 17: More Files 56</p> <p style="margin:0px;">What You Should See 56</p> <p style="margin:0px;">Study Drills 57</p> <p style="margin:0px;">Common Student Questions 57</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 18: Names, Variables, Code, Functions 60</p> <p style="margin:0px;">What You Should See 61</p> <p style="margin:0px;">Study Drills 62</p> <p style="margin:0px;">Common Student Questions 62</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 19: Functions and Variables 64</p> <p style="margin:0px;">What You Should See 65</p> <p style="margin:0px;">Study Drills 65</p> <p style="margin:0px;">Common Student Questions 65</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 20: Functions and Files 68</p> <p style="margin:0px;">What You Should See 69</p> <p style="margin:0px;">Study Drills 69</p> <p style="margin:0px;">Common Student Questions 69</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 21: Functions Can Return Something 72</p> <p style="margin:0px;">What You Should See 73</p> <p style="margin:0px;">Study Drills 73</p> <p style="margin:0px;">Common Student Questions 74</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 22: What Do You Know So Far? 76</p> <p style="margin:0px;">What You Are Learning 76</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 23: Strings, Bytes, and Character Encodings 78</p> <p style="margin:0px;">Initial Research 78</p> <p style="margin:0px;">Switches, Conventions, and Encodings 80</p> <p style="margin:0px;">Disecting the Output 82</p> <p style="margin:0px;">Disecting the Code 82</p> <p style="margin:0px;">Encodings Deep Dive 84</p> <p style="margin:0px;">Breaking It 85</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 24: More Practice 86</p> <p style="margin:0px;">What You Should See 87</p> <p style="margin:0px;">Study Drills 87</p> <p style="margin:0px;">Common Student Questions 87</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 25: Even More Practice 90</p> <p style="margin:0px;">What You Should See 91</p> <p style="margin:0px;">Study Drills 92</p> <p style="margin:0px;">Common Student Questions 93</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 26: Congratulations, Take a Test! 94</p> <p style="margin:0px;">Common Student Questions 94</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 27: Memorizing Logic 96</p> <p style="margin:0px;">The Truth Terms 96</p> <p style="margin:0px;">The Truth Tables 97</p> <p style="margin:0px;">Common Student Questions 98</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 28: Boolean Practice 100</p> <p style="margin:0px;">What You Should See 102</p> <p style="margin:0px;">Study Drills 102</p> <p style="margin:0px;">Common Student Questions 102</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 29: What If 104</p> <p style="margin:0px;">What You Should See 104</p> <p style="margin:0px;">Study Drills 105</p> <p style="margin:0px;">Common Student Questions 105</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 30: Else and If 106</p> <p style="margin:0px;">What You Should See 107</p> <p style="margin:0px;">Study Drills 107</p> <p style="margin:0px;">Common Student Questions 107</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 31: Making Decisions 108</p> <p style="margin:0px;">What You Should See 109</p> <p style="margin:0px;">Study Drills 109</p> <p style="margin:0px;">Common Student Questions 109</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 32: Loops and Lists 112</p> <p style="margin:0px;">What You Should See 113</p> <p style="margin:0px;">Study Drills 114</p> <p style="margin:0px;">Common Student Questions 114</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 33: While Loops 116</p> <p style="margin:0px;">What You Should See 117</p> <p style="margin:0px;">Study Drills 117</p> <p style="margin:0px;">Common Student Questions 118</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 34: Accessing Elements of Lists 120</p> <p style="margin:0px;">Study Drills 121</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 35: Branches and Functions 122</p> <p style="margin:0px;">What You Should See 123</p> <p style="margin:0px;">Study Drills 124</p> <p style="margin:0px;">Common Student Questions 124</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 36: Designing and Debugging 126</p> <p style="margin:0px;">Rules for if-statements 126</p> <p style="margin:0px;">Rules for Loops 126</p> <p style="margin:0px;">Tips for Debugging 127</p> <p style="margin:0px;">Homework 127</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 37: Symbol Review 128</p> <p style="margin:0px;">Keywords 128</p> <p style="margin:0px;">Data Types 129</p> <p style="margin:0px;">String Escape Sequences 130</p> <p style="margin:0px;">Old Style String Formats 130</p> <p style="margin:0px;">Operators 131</p> <p style="margin:0px;">Reading Code 132</p> <p style="margin:0px;">Study Drills 133</p> <p style="margin:0px;">Common Student Questions 133</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 38: Doing Things to Lists 134</p> <p style="margin:0px;">What You Should See 135</p> <p style="margin:0px;">What Lists Can Do 136</p> <p style="margin:0px;">When to Use Lists 137</p> <p style="margin:0px;">Study Drills 137</p> <p style="margin:0px;">Common Student Questions 138</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 39: Dictionaries, Oh Lovely Dictionaries 140</p> <p style="margin:0px;">A Dictionary Example 141</p> <p style="margin:0px;">What You Should See 142</p> <p style="margin:0px;">What Dictionaries Can Do 143</p> <p style="margin:0px;">Study Drills 144</p> <p style="margin:0px;">Common Student Questions 144</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 40: Modules, Classes, and Objects 146</p> <p style="margin:0px;">Modules Are Like Dictionaries 146</p> <p style="margin:0px;">What You Should See 150</p> <p style="margin:0px;">Study Drills 150</p> <p style="margin:0px;">Common Student Questions 151</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 41: Learning to Speak Object-Oriented 152</p> <p style="margin:0px;">Word Drills 152</p> <p style="margin:0px;">Phrase Drills 152</p> <p style="margin:0px;">Combined Drills 153</p> <p style="margin:0px;">A Reading Test 153</p> <p style="margin:0px;">Practice English to Code 155</p> <p style="margin:0px;">Reading More Code 156</p> <p style="margin:0px;">Common Student Questions 156</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 42: Is-A, Has-A, Objects, and Classes 158</p> <p style="margin:0px;">How This Looks in Code 159</p> <p style="margin:0px;">About class Name(object) 161</p> <p style="margin:0px;">Study Drills 161</p> <p style="margin:0px;">Common Student Questions 161</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 43: Basic Object-Oriented Analysis and Design 164</p> <p style="margin:0px;">The Analysis of a Simple Game Engine 165</p> <p style="margin:0px;">Top Down versus Bottom Up 169</p> <p style="margin:0px;">The Code for “Gothons from Planet Percal #25” 170</p> <p style="margin:0px;">What You Should See 176</p> <p style="margin:0px;">Study Drills 176</p> <p style="margin:0px;">Common Student Questions 177</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 44: Inheritance versus Composition 178</p> <p style="margin:0px;">What Is Inheritance? 178</p> <p style="margin:0px;">The Reason for super() 183</p> <p style="margin:0px;">Composition 184</p> <p style="margin:0px;">When to Use Inheritance or Composition 185</p> <p style="margin:0px;">Study Drills 185</p> <p style="margin:0px;">Common Student Questions 186</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 45: You Make a Game 188</p> <p style="margin:0px;">Evaluating Your Game 188</p> <p style="margin:0px;">Function Style 189</p> <p style="margin:0px;">Class Style 189</p> <p style="margin:0px;">Code Style 190</p> <p style="margin:0px;">Good Comments 190</p> <p style="margin:0px;">Evaluate Your Game 190</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 46: A Project Skeleton 192</p> <p style="margin:0px;">macOS/Linux Setup 192</p> <p style="margin:0px;">Windows 10 Setup 194</p> <p style="margin:0px;">Creating the Skeleton Project Directory 195</p> <p style="margin:0px;">Testing Your Setup 197</p> <p style="margin:0px;">Using the Skeleton 198</p> <p style="margin:0px;">Required Quiz 198</p> <p style="margin:0px;">Common Student Questions 198</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 47: Automated Testing 200</p> <p style="margin:0px;">Writing a Test Case 200</p> <p style="margin:0px;">Testing Guidelines 202</p> <p style="margin:0px;">What You Should See 202</p> <p style="margin:0px;">Study Drills 203</p> <p style="margin:0px;">Common Student Questions 203</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 48: Advanced User Input 204</p> <p style="margin:0px;">Our Game Lexicon 204</p> <p style="margin:0px;">A Test First Challenge 206</p> <p style="margin:0px;">What You Should Test 207</p> <p style="margin:0px;">Study Drills 209</p> <p style="margin:0px;">Common Student Questions 209</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 49: Making Sentences 210</p> <p style="margin:0px;">Match and Peek 210</p> <p style="margin:0px;">The Sentence Grammar 211</p> <p style="margin:0px;">A Word on Exceptions 211</p> <p style="margin:0px;">The Parser Code 211</p> <p style="margin:0px;">Playing with the Parser 214</p> <p style="margin:0px;">What You Should Test 215</p> <p style="margin:0px;">Study Drills 215</p> <p style="margin:0px;">Common Student Questions 215</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 50: Your First Website 216</p> <p style="margin:0px;">Installing flask 216</p> <p style="margin:0px;">Make a Simple “Hello World” Project 216</p> <p style="margin:0px;">What’s Going On? 218</p> <p style="margin:0px;">Fixing Errors 218</p> <p style="margin:0px;">Create Basic Templates 219</p> <p style="margin:0px;">Study Drills 221</p> <p style="margin:0px;">Common Student Questions 221</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 51: Getting Input from a Browser 224</p> <p style="margin:0px;">How the Web Works 224</p> <p style="margin:0px;">How Forms Work 226</p> <p style="margin:0px;">Creating HTML Forms 227</p> <p style="margin:0px;">Creating a Layout Template 229</p> <p style="margin:0px;">Writing Automated Tests for Forms 230</p> <p style="margin:0px;">Study Drills 232</p> <p style="margin:0px;">Breaking It 232</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Exercise 52: The Start of Your Web Game 234</p> <p style="margin:0px;">Refactoring the Exercise 43 Game 234</p> <p style="margin:0px;">Creating an Engine 239</p> <p style="margin:0px;">Your Final Exam 241</p> <p style="margin:0px;">Common Student Questions 242</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Next Steps 244</p> <p style="margin:0px;">How to Learn Any Programming Language 245</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Advice from an Old Programmer 246</p> <p style="margin:0px;"></p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix Command Line Crash Course 248</p> <p style="margin:0px;"></p> <p style="margin:0px;">Introduction: Shut Up and Shell 248</p> <p style="margin:0px;">The Setup 249</p> <p style="margin:0px;">Paths, Folders, Directories (pwd) 253</p> <p style="margin:0px;">If You Get Lost 255</p> <p style="margin:0px;">Make a Directory (mkdir) 255</p> <p style="margin:0px;">Change Directory (cd) 258</p> <p style="margin:0px;">List Directory (ls) 261</p> <p style="margin:0px;">Remove Directory (rmdir) 265</p> <p style="margin:0px;">Moving Around (pushd, popd) 268</p> <p style="margin:0px;">Making Empty Files (touch/New-Item) 271</p> <p style="margin:0px;">Copy a File (cp) 272</p> <p style="margin:0px;">Moving a File (mv) 275</p> <p style="margin:0px;">View a File (less/more) 277</p> <p style="margin:0px;">Stream a File (cat) 278</p> <p style="margin:0px;">Removing a File (rm) 280</p> <p style="margin:0px;">Exiting Your Terminal (exit) 282</p> <p style="margin:0px;">Command Line Next Steps 283</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Index 284</p> <!--[if gte mso 9]><xml> Normal 0 false false false EN-US X-NONE X-NONE </xml><![endif]--> <!--[if gte mso 9]><xml> </xml><![endif]--> <!--[if gte mso 10]> <![endif]-->