| Contents at a Glance | 4 |
|---|
| Table of Contents | 5 |
|---|
| About the Author | 9 |
|---|
| About the Technical Reviewer | 10 |
|---|
| Chapter 1: Introducing Python | 11 |
|---|
| Running Python on Various Systems | 11 |
| Installing on Windows | 12 |
| Installing on Other Systems | 12 |
| Choosing the Right Python Version | 12 |
| Understanding the Jargon | 13 |
| Learning While Having Fun | 14 |
| Introducing the Interactive Shell | 14 |
| Choosing to Code with a Text Editor | 15 |
| Choosing to Code with an Integrated Development Environment | 15 |
| Getting Started with Programming | 15 |
| Creating Your Own Help Files | 16 |
| Jargon Busting | 16 |
| Summary | 17 |
| Chapter 2: Designing Software | 18 |
|---|
| Designing Your Own Software (Why Bother?) | 18 |
| Asking the Right Questions | 19 |
| Using Python to Solve Problems | 19 |
| Identifying the Problem | 19 |
| What Do You Want the Software to Do? | 20 |
| Who Will Be Using It? | 20 |
| What System Will Users Be Running It On? | 21 |
| Creating Your Wish List | 21 |
| Talking to Potential Users | 21 |
| Watching Users Perform the Task at Hand | 22 |
| Compiling User Stories | 22 |
| Devising a Solution | 22 |
| Understanding the Problem | 22 |
| Knowing What the Software Needs to Do | 23 |
| Considering Other Needs or Limitations | 23 |
| Defining Acceptable Results | 23 |
| Considering Maintenance | 23 |
| Breaking Down the Solution into Steps | 24 |
| Organizing the Tasks into Steps | 25 |
| Using Indentation and Subgroups | 26 |
| Refining Each Line of Your Pseudocode Until a Solution Is Reached | 26 |
| Coding the Design | 27 |
| Turning the Design into Executable Code | 27 |
| Further Refining the Design | 28 |
| Using functions | 28 |
| Testing the Design | 29 |
| Detecting and correcting coding errors | 30 |
| Noting Modifications, Extensions, and Enhancements | 31 |
| Documenting the Solution | 31 |
| Jargon Busting | 33 |
| Summary | 34 |
| Chapter 3: Variables and Data Types | 35 |
|---|
| Choosing Good Identifiers | 35 |
| Python Keywords | 35 |
| Following the Naming Rules | 36 |
| Creating Variables and Assigning Values | 36 |
| Recognizing Different Types of Variables | 37 |
| Working with Dynamic Typing | 37 |
| In the Beginning Was the Void | 39 |
| Joining Up Text Fragments | 39 |
| Using Quotes | 40 |
| Nesting Quotes | 41 |
| Escaping Sequences | 42 |
| Using Special Whitespace Characters | 42 |
| The More Strings Change the More They Stay the Same | 43 |
| Creating a Text Application | 43 |
| Working with Numbers | 45 |
| Using Binary: Computers Can Only Count to One | 45 |
| Bits and Bytes | 45 |
| Using Booleans: Truth or Dare | 45 |
| Using Whole Numbers (Integers) | 46 |
| Performing Basic Mathematical Operations | 46 |
| Understanding Operator Precedence | 47 |
| Dividing Numbers | 47 |
| Working with Fractions and Floats | 48 |
| Converting One Type into Another | 48 |
| Working with Base 8 (Octal) and Base 16 (Hexadecimal) | 49 |
| Creating a Number Application | 51 |
| Jargon Busting | 53 |
| Summary | 55 |
| Chapter 4: Making Choices | 56 |
|---|
| Comparing Things | 56 |
| Manipulating Boolean Values | 59 |
| Combining Conditional Expressions | 60 |
| Using Assignment Operators | 60 |
| Understanding Operator Precedence | 61 |
| Taking Control of the Process | 62 |
| Using the for Statement | 76 |
| Dealing with Logical Errors | 64 |
| Using Conditional Code in the Application | 68 |
| Now Repeat That | 72 |
| Looping with the while Statement | 72 |
| Now Get Out of That | 74 |
| Nesting Conditional Statements | 76 |
| Jargon Busting | 80 |
| Summary | 81 |
| Chapter 5: Using Lists | 82 |
|---|
| Working with Python Data Structures | 82 |
| Accessing the items in a sequence | 82 |
| If You’re Not on the List, You Can’t Come In | 84 |
| Tuples | 86 |
| Creating a Tuple | 86 |
| Changing the Values in a Tuple | 87 |
| Lists | 87 |
| Creating a List | 87 |
| Modifying a List | 87 |
| Stacks and Queues | 89 |
| Sorting Lists | 89 |
| Multidimensional Lists | 90 |
| Processing Large Amounts of Data Easily | 90 |
| List Comprehensions | 91 |
| Sets | 92 |
| Dictionaries | 93 |
| Defining Dictionaries | 93 |
| Deleting Items | 95 |
| Sorting Dictionaries | 96 |
| Using Dictionaries | 96 |
| A Simple Role-Playing Combat Game | 96 |
| Jargon Busting | 106 |
| Summary | 107 |
| Chapter 6: Functions | 108 |
|---|
| Accessing Privileged Information | 108 |
| Defining Functions | 108 |
| Sending Out Invitations | 109 |
| Passing an Un
|