Head First Programming
Ever wished you could learn how to program from a book? If you have no previous programming experience, you might be wondering where to start. Head First Programming introduces the core concepts of writing computer programs--variables, decisions, loops, functions, and objects--which apply regardless of the programming language, but uses concrete examples and exercises in the dynamic and versatile Python language to apply and reinforce these concepts.
Learn the basic tools to start writing the programs that interests you, not the generic software someone else thinks you should have, and get a better understanding of what software can (and cannot) do. When you're finished, you'll have the necessary foundation to apply to whatever language or software project you need or want to learn.
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 is not Head First Python.
We use release 3 of the Python programming language throughout this book, but this fact alone does not make this book Head First Python. We chose Python because itís a great programming language to start with and itís also a great programming language to grow with. In fact, Python might be the only programming language youíll ever need to learn and use (although your employer might think otherwise). Of course, you have to start with something, and we can think of no better programming language to use than Python when first learning how to program. That said, this book isnít designed to teach you Python; itís designed to teach you programming, so most of the things we show you are designed to hightlight the programming concept, not the Python feature.
You need to install Python 3 on your computer.
To run the programs in this book, you need to download and install Python 3 on your computer. This isnít as hard as it sounds. Pop on over to the Python download site and select the option that fits best with the computer you are using. Just be sure to select release 3 of Python, not release 2: http://www.python.org/download.
We begin by teaching some basic programming concepts, then we start putting programming to work for you right away.
We cover the fundamentals of programming in Chapter 1. That way, by the time you make it all the way to Chapter 2, you are creating programs that actually do something real, useful andógulp!ófun. We are guessing youíll be amazed by how must you can do with less than a dozen lines of code in Chapter 2. The rest of the book then builds on your programming skills turning you from programming newbie to coding ninji master in no time.
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 crossword puzzles are the only thing you donít have to do, but theyíre good for giving your brain a chance to think about the words and terms youíve been learning in a different context.
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 this site so you can copy and paste them as needed.
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.
Code Viewing and Downloads
Download the code by chapter:
- Chapter 1, Starting to Code
- Chapter 2, Textual Data
- Chapter 3, Functions
- Chapter 4, Data in Files and Arrays
- Chapter 5, Hashes and Databases
- Chapter 6, Modular Programming
- Chapter 7, Building a Graphical User Interface
- All Files Chapter 7
- hfprog_sounds.zip [Contains the following files]
- Chapter 8, GUIs and Data
- Chapter 8.5, Exceptions and Message Boxes
- Chapter 9, Graphical Interface Elements
- Chapter 10, Custom Widgets and Classes
- All Files Chapter 10
Selected Review Quotes
"Head First Programming does a great job teaching programming using an iterative process. Add a little, explain a little, make the program a little better. This is how programming works in the real world and Head First Programming makes use of that in a teaching forum. I recommend this book to anyone who wants to start dabbling in programming but doesnít know where to start. Iíd also recommend this book to anyone not necessarily new to programming, but curious about Python. Itís a great intro to programming in general and programming Python specifically."
ó Jeremy Jones, Coauthor of Python for Unix and Linux System Administration
"David Griffiths and Paul Barry have crafted the latest gem in the Head First series. Do you use a computer, but are tired of always using someone elseís software? Is there something you wish your computer would do but wasnít programmed for? In Head First Programming, youíll learn how to write code and make your computer do things your way."
ó Bill Mietelski, Software Engineer
"Head First Programming provides a unique approach to a complex subject. The early chapters make excellent use of metaphors to introduce basic programming concepts used as a foundation for the rest of the book. This book has everything, from web development, to graphical user interfaces and game programming."
ó Doug Hellmann, Senior Software Engineer, Racemi
"A good introduction to programming using one of the best languages around, Head First Programming uses a unique combination of visuals, puzzles, and exercises to teach programming in a way that is approachable and fun."
ó Ted Leung, Principal Software Engineer, Sun Microsystems
(opens a new window)
(opens a new window)
Buy 2 books and get the third free! Use the coupon code OPC10 when you check out.
If you can answer "yes" to all of these:
- Do you wish you had the know-how to control your computer and make it do new things?
- Do you want to learn how to program, so you can create the next big thing in software, make a small fortune, and retire to your own private island?
- 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?
You should probably back away from this book if you can answer "yes" to any of these:
- Are you a seasoned programmer? Do you already know how to program?
- Are you looking for a quick introduction or reference book to Python?
- Would you rather have your toenails pulled out by 15 screaming monkeys than learn something new? Do you believe a programming book should cover everything and if it bores the reader to tears in the process then so much the better?