<p>Preface xi</p> <p>Chapter 1 Introduction to Computers and Programming 1</p> <p>1.1 Introduction 1</p> <p>1.2 Hardware and Software 2</p> <p>1.3 How Computers Store Data 8</p> <p>1.4 How a Program Works 13</p> <p>1.5 Using Python 20</p> <p>Chapter 2 Input, Processing, and Output 31</p> <p>2.1 Designing a Program 31</p> <p>2.2 Input, Processing, and Output 35</p> <p>2.3 Displaying Output with the print Function 36</p> <p>2.4 Comments 39</p> <p>2.5 Variables 40</p> <p>2.6 Reading Input from the Keyboard 49</p> <p>2.7 Performing Calculations 53</p> <p>2.8 More About Data Output 65</p> <p>Chapter 3 Simple Functions 81</p> <p>3.1 Introduction to Functions 81</p> <p>3.2 Defining and Calling a Function 83</p> <p>3.3 Designing a Program to Use Functions 89</p> <p>3.4 Local Variables 95</p> <p>3.5 Passing Arguments to Functions 97</p> <p>3.6 Global Variables and Global Constants 107</p> <p>Chapter 4 Decision Structures and Boolean Logic 117</p> <p>4.1 The if Statement 117</p> <p>4.2 The if-else Statement 125</p> <p>4.3 Comparing Strings 130</p> <p>4.4 Nested Decision Structures and the if-elif-else Statement 134</p> <p>4.5 Logical Operators 142</p> <p>4.6 Boolean Variables 149</p> <p>Chapter 5 Repetition Structures 157</p> <p>5.1 Introduction to Repetition Structures 157</p> <p>5.2 The while Loop: a Condition-Controlled Loop 158</p> <p>5.3 The for Loop: a Count-Controlled Loop 167</p> <p>5.4 Calculating a Running Total 179</p> <p>5.5 Sentinels 182</p> <p>5.6 Input Validation Loops 185</p> <p>5.7 Nested Loops 190</p> <p>Chapter 6 Value-Returning Functions and Modules 203</p> <p>6.1 Introduction to Value-Returning Functions: Generating Random Numbers 203</p> <p>6.2 Writing Your Own Value-Returning Functions 214</p> <p>6.3 The math Module 225</p> <p>6.4 Storing Functions in Modules 228</p> <p>Chapter 7 Files and Exceptions 239</p> <p>7.1 Introduction to File Input and Output 239</p> <p>7.2 Using Loops to Process Files 256</p> <p>7.3 Processing Records 263</p> <p>7.4 Exceptions 276</p> <p>Chapter 8 Lists and Tuples 295</p> <p>8.1 Sequences 295</p> <p>8.2 Introduction to Lists 295</p> <p>8.3 List Slicing 303</p> <p>8.4 Finding Items in Lists with the in Operator 306</p> <p>8.5 List Methods and Useful Built-in Functions 307</p> <p>8.6 Copying Lists 314</p> <p>8.7 Processing Lists 316</p> <p>8.8 Two-Dimensional Lists 328</p> <p>8.9 Tuples 332</p> <p>Chapter 9 More About Strings 341</p> <p>9.1 Basic String Operations 341</p> <p>9.2 String Slicing 349</p> <p>9.3 Testing, Searching, and Manipulating Strings 353</p> <p>Chapter 10 Dictionaries and Sets 371</p> <p>10.1 Dictionaries 371</p> <p>10.2 Sets 394</p> <p>10.3 Serializing Objects 406</p> <p>Chapter 11 Classes and Object-Oriented Programming 421</p> <p>11.1 Procedural and Object-Oriented Programming 421</p> <p>11.2 Classes 425</p> <p>11.3 Working with Instances 442</p> <p>11.4 Techniques for Designing Classes 464</p> <p>Chapter 12 Inheritance 483</p> <p>12.1 Introduction to Inheritance 483</p> <p>12.2 Polymorphism 498</p> <p>Chapter 13 Recursion 509</p> <p>13.1 Introduction to Recursion 509</p> <p>13.2 Problem Solving with Recursion 512</p> <p>13.3 Examples of Recursive Algorithms 516</p> <p>Chapter 14 GUI Programming 529</p> <p>14.1 Graphical User Interfaces 529</p> <p>14.2 Using the tkinter Module 531</p> <p>14.3 Display Text with Label Widgets 534</p> <p>14.4 Organizing Widgets with Frames 537</p> <p>14.5 Button Widgets and Info Dialog Boxes 540</p> <p>14.6 Getting Input with the Entry Widget 543</p> <p>14.7 Using Labels as Output Fields 546</p> <p>14.8 Radio Buttons and Check Buttons 554</p> <p>Appendix C The ASCII Character Set 577</p> <p>Appendix D Answers to Checkpoints 579</p> <p></p>Index <p></p> <p>595</p> <p> </p>