Contents......Page 2 --- Core Language......Page 7 Introduction......Page 8 Why Python?......Page 9 Why Another Tutorial?......Page 10 Getting Python......Page 11 Conventions Used in this Book......Page 12 How is Python Different......Page 13 Comparison of Programming Languages......Page 17 C......Page 18 C++......Page 19 Java......Page 20 C#......Page 22 Python......Page 26 Launching the Python interpreter......Page 28 Python Versions......Page 30 Using the Python Command Prompt......Page 31 Launching Python programs......Page 32 Integrated Development Environments......Page 33 Python Syntax......Page 35 Python Object Types......Page 37 Python Numbers......Page 38 Strings......Page 41 Basic string operations......Page 42 Indexing and slicing strings......Page 44 String Formatting......Page 45 Combining and Separating Strings......Page 47 Regular Expressions......Page 49 Lists......Page 50 List usage......Page 51 Adding List Elements......Page 52 Methods......Page 55 Dictionaries......Page 57 Making a dictionary......Page 58 Basic operations......Page 59 Operation......Page 61 Tuples......Page 62 Why Use Tuples?......Page 63 Sequence Unpacking......Page 64 Methods......Page 65 Files......Page 67 Files and Streams......Page 68 Creating a File......Page 69 Reading From a File......Page 70 Iterating Through Files......Page 73 Seeking......Page 74 Serialization......Page 75 Statements......Page 77 Assignment......Page 78 Expressions/Calls......Page 79 Printing......Page 80 if Tests......Page 81 while Loops......Page 83 for Loops......Page 84 pass Statement......Page 86 def and return Statements......Page 87 Class Statements......Page 88 Documenting Code......Page 89 Making a Program......Page 96 Making Python Do Something......Page 97 Scope......Page 100 Default Arguments......Page 101 Exceptions......Page 103 Exception Class Hierarchy......Page 106 User-Defined Exceptions......Page 108 Learning Python Classes......Page 110 Improving Your Class Standing......Page 111 So What Does a Class Look Like?......Page 113 “New-style” classes......Page 115 A Note About Style......Page 116 Inheritance......Page 117 Operator Overloads......Page 119 Class Methods......Page 121 Have you seen my class?......Page 122 Databases......Page 124 Working With a Database......Page 125 Using SQL to Query a Database......Page 126 Creating an SQLite DB......Page 128 Pulling Data from a DB......Page 130 SQLite Database Files......Page 133 Distributing a Program......Page 135 Python 3......Page 137 --- GUIs......Page 139 Introduction......Page 140 Popular GUI Frameworks......Page 141 Before You Start......Page 143 Simple Graphical Dice Roller......Page 145 What can wxPython do......Page 151 String Methods......Page 153 List Methods......Page 159 Dictionary Operations......Page 161 Operators......Page 165 Dice rolling simulator......Page 167 Temperature conversion......Page 171 Game character attribute generator......Page 172 Text-based character creation......Page 175 An introduction to computer programming, using the easy, yet powerful, Python programming language. Python, a cross-platform language used by such organizations as Google and NASA, lets you work quickly and efficiently, allowing you to concentrate on your work rather than the language. The core Python language (both versions 2.x and 3.x) is discussed, as well as an introduction to graphical user interface creation. The ideas covered in this book provide the reader with many major programming topics, applicable to a wide variety of programming languages. After reading this book, the reader should be able to quickly create simple to medium-level programs and be prepared to tackle more complex programming tasks.