Learn Python the Hard Way

Learn Python the Hard Way : A Very Simple Introduction to the Terrifyingly Beautiful World of Computers and Code

3.9 (889 ratings by Goodreads)
By (author) 

Free delivery worldwide

Available. Dispatched from the UK in 2 business days
When will my order arrive?

Not expected to be delivered to the United States by Christmas Not expected to be delivered to the United States by Christmas


You Will Learn Python! Zed Shaw has perfected the world's best system for learning Python. Follow it and you will succeed-just like the hundreds of thousands of beginners Zed has taught to date! You bring the discipline, commitment, and persistence; the author supplies everything else. In Learn Python the Hard Way, Third Edition, you'll learn Python by working through 52 brilliantly crafted exercises. Read them. Type their code precisely. (No copying and pasting!) Fix your mistakes. Watch the programs run. As you do, you'll learn how software works; what good programs look like; how to read, write, and think about code; and how to find and fix your mistakes using tricks professional programmers use. Most importantly, you'll learn the following, which you need to start writing excellent Python software of your own: Installing a complete Python environment Organizing and writing code Basic mathematics Variables Strings and text Interacting with users Working with files Looping and logic Data structures using lists and dictionaries Program design Object-oriented programming Inheritance and composition Modules, classes, and objects Python packaging Debugging Automated testing Basic game development Basic web development It'll be hard at first. But soon, you'll just get it-and that will feel great! This tutorial will reward you for every minute you put into it. Soon, you'll know one of the world's most powerful, popular programming languages. You'll be a Python programmer. Watch Zed, too! The accompanying DVD contains 5+ hours of passionate, powerful teaching: a complete Python video course!show more

Product details

  • Mixed media product | 320 pages
  • 175.26 x 228.6 x 20.32mm | 521.63g
  • Pearson Education (US)
  • Addison-Wesley Educational Publishers Inc
  • New Jersey, United States
  • English
  • 3rd edition
  • 0321884914
  • 9780321884916
  • 16,934

About Zed A. Shaw

Zed A. Shaw is the author of the popular online books Learn Python the Hard Way, Learn Ruby the Hard Way, and Learn C the Hard Way. He is also the creator of several open source software projects like Mongrel, Lamson, Mongrel2, and has been programming and writing for nearly 20 years.show more

Table of contents

Preface 1Acknowledgments 1The Hard Way Is Easier 1Do Not Copy-Paste 2A Note on Practice and Persistence 3A Warning for the Smarties 3 Exercise 0: The Setup 6Mac OSX 6Windows 7Linux 9Warnings for Beginners 10 Exercise 1: A Good First Program 12What You Should See 14Study Drills 15Common Student Questions 16 Exercise 2: Comments and Pound Characters 18What You Should See 18Study Drills 18Common Student Questions 19 Exercise 3: Numbers and Math 20What You Should See 21Study Drills 21Common Student Questions 22 Exercise 4: Variables and Names 24What You Should See 25Study Drills 25Common Student Questions 25 Exercise 5: More Variables and Printing 28What You Should See 28Study Drills 29Common Student Questions 29 Exercise 6: Strings and Text 30What You Should See 31Study Drills 31Common Student Questions 31 Exercise 7: More Printing. 32What You Should See 32Study Drills 32Common Student Questions 33 Exercise 8: Printing, Printing 34What You Should See 34Study Drills 34Common Student Questions 34 Exercise 9: Printing, Printing, Printing 36What You Should See 36Study Drills 36Common Student Questions 37 Exercise 10: What Was That? 38What You Should See 39Escape Sequences 39Study Drills 40Common Student Questions 40 Exercise 11: Asking Questions 42What You Should See 42Study Drills 43Common Student Questions 43 Exercise 12: Prompting People 44What You Should See 44Study Drills 44Common Student Questions 45 Exercise 13: Parameters, Unpacking, Variables 46Hold Up! Features Have Another Name 46What You Should See 47Study Drills 48Common Student Questions 48 Exercise 14: Prompting and Passing 50What You Should See 50Study Drills 51Common Student Questions 51 Exercise 15: Reading Files 54What You Should See 55Study Drills 55Common Student Questions 56 Exercise 16: Reading and Writing Files 58What You Should See 59Study Drills 59Common Student Questions 60 Exercise 17: More Files 62What You Should See 63Study Drills 63Common Student Questions 63 Exercise 18: Names, Variables, Code, Functions 66What You Should See 67Study Drills 68Common Student Questions 68 Exercise 19: Functions and Variables 70What You Should See 71Study Drills 71Common Student Questions 71 Exercise 20: Functions and Files 74What You Should See 75Study Drills 75Common Student Questions 75 Exercise 21: Functions Can Return Something 78What You Should See 79Study Drills 79Common Student Questions 80 Exercise 22: What Do You Know So Far? 81What You Are Learning 81 Exercise 23: Read Some Code 82 Exercise 24: More Practice 84What You Should See 85Study Drills 85Common Student Questions 85 Exercise 25: Even More Practice 86What You Should See 87Study Drills 88Common Student Questions 89 Exercise 26: Congratulations, Take a Test! 90Common Student Questions 90 Exercise 27: Memorizing Logic 92The Truth Terms 92The Truth Tables 93Common Student Questions 94 Exercise 28: Boolean Practice 96What You Should See 98Study Drills 98Common Student Questions 98 Exercise 29: What If 100What You Should See 100Study Drills 101Common Student Questions 101 Exercise 30: Else and If 102What You Should See 103Study Drills 103Common Student Questions 103 Exercise 31: Making Decisions 104What You Should See 105Study Drills 105Common Student Questions 105 Exercise 32: Loops and Lists 106What You Should See 107Study Drills 108Common Student Questions 108 Exercise 33: While-Loops 110What You Should See 111Study Drills 111Common Student Questions 112 Exercise 34: Accessing Elements of Lists 114Study Drills 115 Exercise 35: Branches and Functions 116What You Should See 117Study Drills 118Common Student Questions 118 Exercise 36: Designing and Debugging 120Rules for If-Statements 120Rules for Loops 120Tips for Debugging 121Homework 121 Exercise 37: Symbol Review 122Keywords 122Data Types 123String Escape Sequences 124String Formats 124Operators 125Reading Code 126Study Drills 127Common Student Questions 127 Exercise 38: Doing Things to Lists 128What You Should See 129Study Drills 130Common Student Questions 130 Exercise 39: Dictionaries, Oh Lovely Dictionaries 132What You Should See 134Study Drills 135Common Student Questions 135 Exercise 40: Modules, Classes, and Objects 138Modules Are Like Dictionaries 138What You Should See 142Study Drills 142Common Student Questions 143 Exercise 41: Learning to Speak Object Oriented 144Word Drills 144Phrase Drills 144Combined Drills 145A Reading Test 145Practice English to Code 147Reading More Code 148Common Student Questions 148 Exercise 42: Is-A, Has-A, Objects, and Classes 150How This Looks in Code 151About class Name(object) 153Study Drills 153Common Student Questions 154 Exercise 43: Basic Object-Oriented Analysis and Design 156The Analysis of a Simple Game Engine 157Top Down vs. Bottom Up 161The Code for "Gothons from Planet Percal #25" 162What You Should See 167Study Drills 168Common Student Questions 168 Exercise 44: Inheritance vs. Composition 170What Is Inheritance? 170The Reason for super() 175Composition 176When to Use Inheritance or Composition 177Study Drills 177Common Student Questions 178 Exercise 45: You Make a Game 180Evaluating Your Game 180Function Style 181Class Style 181Code Style 182Good Comments 182Evaluate Your Game 183 Exercise 46: A Project Skeleton 184Installing Python Packages 184Creating the Skeleton Project Directory 185Testing Your Setup 187Using the Skeleton 188Required Quiz 188Common Student Questions 189 Exercise 47: Automated Testing 190Writing a Test Case 190Testing Guidelines 192What You Should See 192Study Drills 193Common Student Questions 193 Exercise 48: Advanced User Input 194Our Game Lexicon 194What You Should Test 196Design Hints 198Study Drills 198Common Student Questions 198 Exercise 49: Making Sentences 200Match and Peek 200The Sentence Grammar 201A Word on Exceptions 203What You Should Test 204Study Drills 204Common Student Questions 204 Exercise 50: Your First Website 206Installing lpthw.web 206Make a Simple "Hello World" Project 207What's Going On? 208Fixing Errors 209Create Basic Templates 209Study Drills 211Common Student Questions 211 Exercise 51: Getting Input from a Browser 214How the Web Works 214How Forms Work 216Creating HTML Forms 218Creating a Layout Template 220Writing Automated Tests for Forms 221Study Drills 223Common Student Questions 224 Exercise 52: The Start of Your Web Game 226Refactoring the Exercise 43 Game 226Sessions and Tracking Users 231Creating an Engine 232Your Final Exam 235Common Student Questions 236 Next Steps 237How to Learn Any Programming Language 238 Advice from an Old Programmer 241 Appendix: Command Line Crash Course 243Introduction: Shut Up and Shell 243Exercise 1: The Setup 245Exercise 2: Paths, Folders, Directories (pwd) 248Exercise 3: If You Get Lost 250Exercise 4: Make a Directory (mkdir) 250Exercise 5: Change Directory (cd) 252Exercise 6: List Directory (ls) 256Exercise 7: Remove Directory (rmdir) 260Exercise 8: Move Around (pushd, popd) 262Exercise 9: Make Empty Files (Touch, New-Item) 265Exercise 10: Copy a File (cp) 266Exercise 11: Move a File (mv) 269Exercise 12: View a File (less, MORE) 271Exercise 13: Stream a File (cat) 272Exercise 14: Remove a File (rm) 273Exercise 15: Exit Your Terminal (exit) 275Command Line Next Steps 276 Index 279show more

Rating details

889 ratings
3.9 out of 5 stars
5 30% (266)
4 41% (363)
3 21% (187)
2 6% (52)
1 2% (21)
Book ratings by Goodreads
Goodreads is the world's largest site for readers with over 50 million reviews. We're featuring millions of their reader ratings on our book pages to help you find your new favourite book. Close X