A Learner's Guide to Programming Using the Python Language.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Advance Praise for Head First Programming “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 Praise for other Head First books “Kathy and Bert’s Head First Java transforms the printed page into the closest thing to a GUI you’ve ever seen. In a wry, hip manner, the authors make learning Java an engaging ‘what’re they gonna do next?’ experience.” — Warren Keuffel, Software Development Magazine “Beyond the engaging style that drags you forward from know-nothing into exalted Java warrior status, Head First Java covers a huge amount of practical matters that other texts leave as the dreaded ‘exercise for the reader....’ It’s clever, wry, hip and practical—there aren’t a lot of textbooks that can make that claim and live up to it while also teaching you about object serialization and network launch protocols.” — Dr. Dan Russell, Director of User Sciences and Experience Research IBM Almaden Research Center (and teaches Artificial Intelligence at Stanford University) “It’s fast, irreverent, fun, and engaging. Be careful—you might actually learn something!” — Ken Arnold, former Senior Engineer at Sun Microsystems Coauthor (with James Gosling, creator of Java), The Java Programming Language “I feel like a thousand pounds of books have just been lifted off of my head.” — Ward Cunningham, inventor of the Wiki and founder of the Hillside Group “Just the right tone for the geeked-out, casual-cool guru coder in all of us. The right reference for practi- cal development strategies—gets my brain going without having to slog through a bunch of tired, stale professor -speak.” — Travis Kalanick, Founder of Scour and Red Swoosh Member of the MIT TR100 “There are books you buy, books you keep, books you keep on your desk, and thanks to O’Reilly and the Head First crew, there is the penultimate category, Head First books. They’re the ones that are dog-eared, mangled, and carried everywhere. Head First SQL is at the top of my stack. Heck, even the PDF I have for review is tattered and torn.” — Bill Sawyer, ATG Curriculum Manager, Oracle “This book’s admirable clarity, humor and substantial doses of clever make it the sort of book that helps even non-programmers think well about problem-solving.” — Cory Doctorow, co-editor of Boing Boing Author, Down and Out in the Magic Kingdom and Someone Comes to Town, Someone Leaves Town Praise for other Head First books “I received the book yesterday and started to read it... and I couldn’t stop. This is definitely très ‘cool.’ It is fun, but they cover a lot of ground and they are right to the point. I’m really impressed.” — Erich Gamma, IBM Distinguished Engineer, and co-author of Design Patterns “One of the funniest and smartest books on software design I’ve ever read.” — Aaron LaBerge, VP Technology, ESPN.com “What used to be a long trial and error learning process has now been reduced neatly into an engaging paperback.” — Mike Davidson, CEO, Newsvine, Inc. “Elegant design is at the core of every chapter here, each concept conveyed with equal doses of pragmatism and wit.” — Ken Goldstein, Executive Vice President, Disney Online “I ♥ Head First HTML with CSS & XHTML—it teaches you everything you need to learn in a ‘fun coated’ format.” — Sally Applin, UI Designer and Artist “Usually when reading through a book or article on design patterns, I’d have to occasionally stick myself in the eye with something just to make sure I was paying attention. Not with this book. Odd as it may sound, this book makes learning about design patterns fun. “While other books on design patterns are saying ‘Buehler… Buehler… Buehler…’ this book is on the float belting out ‘Shake it up, baby!’” — Eric Wuehler “I literally love this book. In fact, I kissed this book in front of my wife.” — Satish Kumar Other related books from O’Reilly Learning Python Programming Python Python Cookbook Other books in O’Reilly’s Head First series Head First JavaTM Head First Object-Oriented Analysis and Design (OOA&D) Head First HTML with CSS and XHTML Head First Design Patterns Head First Data Analysis Head First Servlets and JSP Head First EJB Head First PMP Head First SQL Head First Software Development Head First JavaScript Head First Ajax Head First Physics Head First Statistics Head First Rails Head First PHP & MySQL Head First Algebra Head First Web Design Head First Programming Wouldn‛t it be dreamy if there were an introductory programming book that didn‛t make you wish you were anywhere other than stuck in front of your computer writing code? I guess it‛s just a fantasy... Paul Barry David Griffiths Beijing • Cambridge • Farnham • Kln • Sebastopol • Taipei • Tokyo Head First Programming by Paul Barry and David Griffiths Copyright © 2009 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Series Creators: Kathy Sierra, Bert Bates Series Editor: Brett D. McLaughlin Editor: Brian Sawyer Cover Designers: Steve Fehler Production Editor: Scott DeLugan Proofreader: Colleen Toporek Deirdre Indexer: Angela Howard (super mom) Page Viewers: David: Dawn; Paul: Deirdre, Joseph, Aaron, and Aideen Printing History: November 2009: First Edition. Paul Dawn (without whom the book Aideen (future would never have singer/songwriter) been finished) The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. The Head First series designations, Aaron and Joseph Head First Programming, and related trade dress are trademarks of O’Reilly Media, Inc. (real-life surfer Many of the designations used by manufacturers and sellers to distinguish their products are claimed as dudes) trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and the authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. No surfers or snakes were harmed in the making of this book. TM This book uses RepKover™, a durable and flexible lay-flat binding. ISBN: 978-0-596-80237-0 [C] We dedicate this book to the first person who looked at a computer and then asked the question, “I wonder how I make it do this... ?” And to those that made programming complex enough that people need a book like ours to learn it. David: To Dawn. The smartest person I know. Paul: This one’s dedicated to my father, Jim Barry, who, 25 years ago—when I needed a push—pushed me toward computing. That was a good push. the authors Authors of Head First Programming Paul Barry David Griffiths Paul Barry recently worked out that he has David Griffiths began programming at age 12, been programming for close to a quarter century, a when he saw a documentary on the work of Seymour fact that came as a bit of a shock. In that time, Paul Papert. At age 15, he wrote an implementation of has programmed in lots of different programming Papert’s computer language LOGO. After studying languages, lived and worked in two countries on two Pure Mathematics at University, he began writing code continents, got married, had three kids (well... his wife for computers and magazine articles for humans. He’s Deirdre actually had them, but Paul did play his part), worked as an agile coach, a developer, and a garage completed a B.Sc. and M.Sc. in Computing, written attendant, but not in that order. He can write code in two other books, written a bunch of technical articles over 10 languages and prose in just one, and when not for Linux Journal, and managed not to lose his hair..