Python_Programming_Fundamentals_2E_Kent

1Introduction .

1.1 The Python Programming Language . 1.2 Installing Python and Wing IDE 101. 1.3 Writing Your First Program . 1.4 What Is a Computer? . 1.5 Binary Number Representation . 1.6 What Is a Programming Language?. 1.7 Hexadecimal and Octal Representation . 1.8 Writing Your Second Program . 1.9 Syntax Errors . 1.10 Types of Values . 1.11 The Reference Type and Assignment Statements . 1.12 Integers and Real Numbers . 1.13 Strings. 1.14 Integer to String Conversion and Back Again . 1.15 Getting Input . 1.16 Formatting Output. 1.17 When Things Go Wrong . 1.18 Review Questions . 1.19 Exercises . 1.20 Solutions to Practice Problems .1

2Decision Making .

2.1 Finding the Max of Three Integers . 2.2 The Guess and Check Pattern . 2.3 Choosing from a List of Alternatives. 2.4 The Boolean Type . 2.5 Short Circuit Logic . 2.6 Comparing Floats for Equality . 2.7 Exception Handling. 2.8 Review Questions . 2.9 Exercises . 2.10 Solutions to Practice Problems .39

3Repetitive Tasks .

3.1 Operators . 3.2 Iterating Over a Sequence . 3.3 Lists . 3.4 The Guess and Check Pattern for Lists . 3.5 Mutability of Lists . 3.6 The Accumulator Pattern . 3.7 Reading from and Writing to a File. 3.8 Reading Records from a File . 3.9 Review Questions . 3.10 Exercises . 3.11 Solutions to Practice Problems .63

4Using Objects .

4.1 Constructors . 4.2 Accessor Methods. 4.3 Mutator Methods . 4.4 Immutable Classes . 4.5 Object-Oriented Programming . 4.6 Working with XML Files. 4.7 Extracting Elements from an XML File . 4.8 XML Attributes and Dictionaries . 4.9 Reading an XML File and Building Parallel Lists . 4.10 Using Parallel Lists to Draw a Picture . 4.11 Review Questions . 4.12 Exercises . 4.13 Solutions to Practice Problems .91

5Defining Functions .

5.1 Why Write Functions?. 5.2 Passing Arguments and Returning a Value. 5.3 Scope of Variables . 5.4 The Run-Time Stack . 5.5 Mutable Data and Functions. 5.6 Predicate Functions . 5.7 Top-Down Design . 5.8 Bottom-Up Design . 5.9 Recursive Functions . 5.10 The Main Function . 5.11 Keyword Arguments . 5.12 Default Values . 5.13 Functions with Variable Number of Parameters . 5.14 Dictionary Parameter Passing .115 5.15 Review Questions . 5.16 Exercises . 5.17 Solutions to Practice Problems .137

6Event-Driven Programming .

6.1 The Root Window . 6.2 Menus . 6.3 Frames . 6.4 The Text Widget . 6.5 The Button Widget . 6.6 Creating a Reminder! . 6.7 Finishing up the Reminder! Application. 6.8 Label and Entry Widgets . 6.9 Layout Management . 6.10 Message Boxes. 6.11 Review Questions . 6.12 Exercises . 6.13 Solutions to Practice Problems .145

7Defining Classes .

7.1 Creating an Object . 7.2 Inheritance . 7.3 A Bouncing Ball Example . 7.4 Polymorphism . 7.5 Getting Hooked on Python. 7.6 Review Questions . 7.7 Exercises . 7.8 Solutions to Practice Problems .163

8Appendix A: Integer Operators .189 9Appendix B: Float Operators .191 10Appendix C: String Operators and Methods .193 11Appendix D: List Operators and Methods .197 12Appendix E: Dictionary Operators and Methods .199 13Appendix F: Turtle Methods .201xii 14Appendix G: TurtleScreen Methods.213 15Appendix H: The Reminder! Program.221 16Appendix I: The Bouncing Ball Program .225 Glossary .229 References.235 Index .2371