Head First Python

<em>Head First Python</em>

Ever wished you could learn Python from a book? Head First Python helps you learn the language through a unique method that goes beyond syntax and how-to manuals. You'll quickly grasp Python's fundamentals, then move on to persistence, exception handling, web development, SQLite, data wrangling, and Google App Engine. You'll also learn how to write mobile apps for Android, all thanks to the power that Python gives you. Head First Python is a complete learning experience that will help you become a bona fide Python programmer.

A collection of images from inside the book.

Code and Python Example Downloads

Download all code and Python examples (zip file)

Download by chapter:
  1. Meet Python: Everyone Loves Lists
  2. Sharing Your Code: Modules of Functions
  3. Files and Exceptions: Dealing with Errors
  4. Persistence: Saving Data to Files
  5. Comprehending Data: Work That Data!
  6. Custom Data Objects: Bundling Code with Data
  7. Web Development: Putting it All Together
  8. Mobile App Development: Small Devices
  9. Manage Your Data: Handling Input
  10. Scaling Your Webapp: Getting Real
  11. Dealing with Complexity: Data Wrangling

Read Me:
What you should know before reading this book

This is a learning experience, not a reference book. We deliberately stripped out everything that might get in the way of learning whatever it is we're working on at that point in the book. And the first time through, you need to begin at the beginning, because the book makes assumptions about what you've already seen and learned.

This book is designed to get you up to speed with Python as quickly as possible.

As you need to know stuff, we teach it. So you won't find long lists of technical material, no tables of Python's operators, not its operator precedence rules. We don't cover everything, but we've worked really hard to cover the essential material as well as we can, so that you can get Python into your brain quickly and have it stay there. The only assumption we make is that you already know how to program in some other programming language.

This book targets Python 3

We use Release 3 of the Python programming language in this book, and we cover how to get and install Python 3 in the first chapter. That said, we don't completely ignore Release 2, as you'll discover in Chapters 8 through 11. But trust us, by then you'll be so happy using Python you won't notice that the technologies you're programming are running Python 2.

We put Python to work for you right away.

We get you doing useful stuff in Chapter 1 and build from there. There's no hanging around, because we want you to be productive with Python right away.

The activities are NOT optional.

The exercises and activities are not add-ons; they're part of the core content of the book. Some of them are to help with memory, some are for understanding, and some will help you apply what you've learned. Don't skip the exercises.

The redundancy is intentional and important.

One distinct difference in a Head First book is that we want you to really get it. And we want you to finish the book remembering what you've learned. Most reference books don't have retention and recall as a goal, but this book is about learning, so you'll see some of the same concepts come up more than once.

The examples are as lean as possible.

Our readers tell us that it's frustrating to wade through 200 lines of an example looking for the two lines they need to understand. Most examples in this book are shown within the smallest possible context, so that the part you're trying to learn is clear and simple. Don't expect all of the examples to be robust, or even complete—they are written specifically for learning, and aren't always fully-functional.

We've placed a lot of the code examples on the Web so you can copy and paste them as needed. You'll find them at two locations:

http://www.headfirstlabs.com/books/hfpython/ and http://python.itcarlow.ie

The Brain Power exercises don't have answers.

For some of them, there is no right answer, and for others, part of the learning experience of the Brain Power activities is for you to decide if and when your answers are right. In some of the Brain Power exercises, you will find hints to point you in the right direction.

Selected Review Quotes

"Head First Python is a great introduction to not just the Python language, but Python as it's used in the real world. The book goes beyond the syntax to teach you how to create applications for Android phones, Google's App Engine, and more."
— David Griffiths, author and Agile coach
"Where other books start with theory and progress to examples, Head First Python jumps right in with code and explains the theory as you read along. This is a much more effective learning environment, because it engages the reader to do from the very beginning. It was also just a joy to read. It was fun without being flippant and informative without being condescending. The breadth of examples and explanation covered the majority of what you'll use in your job every day. I'll recommend this book to anyone starting out on Python."
— Jeremy Jones, coauthor of Python for Unix and Linux System Administration
"Head First Python is a terrific book for getting a grounding in a language that is increasing in relevance day by day."
— Phil Hartley, University of Advancing Technology
Order
(opens a new window)

Buy 2 books, get 1 free!

Buy 2 books and get the third free! Use the coupon code OPC10 when you check out.

Who is this book for?

If you can answer "yes" to all of these:

  • Do you already know how to program in another programming language?
  • Do you wish you had the know-how to program Python, add it to your list of tools, and make it do new things?
  • Do you prefer actually doing things and applying the stuff you learn over listening to someone in a lecture rattle on for hours on end?

Who should probably back away from this book? If you can answer "yes" to any of these:

  • Do you already know most of what you need to know to program with Python?
  • Are you looking for a reference book to Python, one that covers all the details in excruciating detail?
  • Would you rather have your toenails pulled out by 15 screaming monkeys than learn something new? Do you believe a Python book should cover everything and if it bores the reader to tears then so much the better?

Related Head First Titles

Head First Programming
By David Griffiths, Paul Barry