Preface
This simple book is meant to get you started in programming. The title says it’s the hard way to learn to write code, but it’s actually not. It’s only the «hard» way because it uses a technique called instruction. Instruction is where I tell you to do a sequence of controlled exercises designed to build a skill through repetition. This technique works very well with beginners who know nothing and need to acquire basic skills before they can understand more complex topics. It’s used in everything from martial arts to music to even basic math and reading skills.
This book instructs you in Python by slowly building and establishing skills through techniques such as practice and memorization, then applying them to increasingly difficult problems. By the end of the book you will have the tools needed to begin learning more complex programming topics. I like to tell people that my book gives you your «programming black belt.» What this means is that you know the basics well enough to now start learning programming.
If you work hard, take your time, and build these skills, you will learn to code.
Improvements in the First Edition for Python 3
This first edition for Python 3 of Learn Python The Hard Way now uses Python 3.6. I’ve standardized on this version of Python because it has a new improved string formatting system that is easier to use than the previous 4 (or 3, I forget, there were many). There are a few problems with Python 3.6 for beginners, but I’ll be helping you navigate these issues in the book. A particularly hairy problem is Python 3.6 has very poor error messages in some key areas that I’ll be helping you understand.
I have also improved the videos based on my experiences over the last five years teaching people Python. In the past the videos simply let you watch me do the exercise. The fourth edition videos also show you how to break—and then fix—every exercise. This skill is called «debugging.» It will teach you how to fix problems you run into but also how Python runs the programs you’re creating. The goal of this new methodology is to build a mental model of how Python runs your code so you can more easily figure out why it’s broken. You’ll also learn many useful tricks for debugging broken software.
Lastly, the fourth edition fully supports Microsoft Windows 10 from beginning to end. The previous edition focused mostly on the Unix style systems such as macOS and Linux, with Windows being more of an afterthought. At the time I started writing the fourth edition Microsoft had started to take open source tools and developers seriously, and it was difficult to ignore them as a serious Python development platform. The videos will feature Microsoft windows using Python in various scenarios and will also show macOS and Linux for full compatibility. I’ll tell you about any gotchas on each platform, cover installation instructions, and provide any other tips I can give you.
Acknowledgements
I would like to thank Angela for helping me with the first two versions of this book. Without her I probably wouldn’t have bothered to finish it at all. She did the copy-editing of the first draft and supported me immensely while I wrote it.
I’d also like to thank Greg Newman for doing the original cover art, Brian Shumate for early website designs, and all of the people who read this book and took the time to send me feedback and corrections.
Buy The Python 3 Edition!
When you buy Learn Python 3 The Hard Way, you’ll receive the Python 3 Edition PDF, special access to a paid HTML version, and 12 hours of 1080p video, one video for each exercise. All files are DRM free and you can download them to your computer for offline viewing. Digital Download Only! You do not get a physical book.
Millions of people have learned to code. So can you.
Newly updated for Python 3, the original and still the most popular way for total beginners to finally learn how to code. Learn Python The Hard Way takes you from absolute zero to able to read and write basic Python to then understand other books on Python. No experience necessary to begin, and you can even try the book out for free to see if the method works for you. If you’ve always wanted to learn to code but have no idea where to begin, then this book is for you.
Thanks so much for putting your book online. It has served as a tremendous resource on learning python and just wanted to say I really appreciate it. People like you make this world a better place.
Michael
Hey man just wanted to say you really made it easy to learn from being a beginner. The command line does suck and is really boring but I can tell once I start becoming familiar with it everyday it will be second nature.
Kennon
Just wanted to send a quick thank you for giving me confidence in trying to learn to code. I’m 28 now and didn’t think it was something I could do – (it still might not be) – but thanks to your book it’s given me an opportunity I don’t want to miss out on. Love your passion and it’s very inspiring.
Peter
I started doing your Python course when I was unemployed. and it made a huge difference in my life. Because I had some programming knowledge, I was able to get a job for a financial company that needed someone who could do a bit of coding in addition to their regular duties. . Now, I’ve gone from being one of the long-term unemployed to looking at buying my first home.
Marshal
Briefly I’m a 61 year old retire[d] business consultant who has always love computers. Decided to learn programming and starting with your course. As one who has done lots of teaching allow me to compliment the course and your style. Just finished Exercise 12 and wanted to say thanks for putting this course together!
Bert
I’ve just bought Learn C the Hard Way while on a business trip, since the beta edition website has been incredibly useful. Thanks for that, by the way! Writing the simple database with dynamically allocated fields was more empowering than almost anything I’ve done as a programmer so far.
Roman
Also I may as well take the opportunity to mention that as a PHP dev the C course is exactly what I was looking for and is frankly excellent. So thank you very much!
Michael
I would like to say that I find your material absolutely terrific. Very pedagogical and methodical, taking it nice and slow. Perfect for a beginner and someone who thinks that technology can be a little intimidating like me. I’ve been running my own businesses for some years and have come to the realization how important it is to know at least some coding. Most importantly in order to be able to talk to and understand programmers (and balance up the information asymmetry), as well as making your own prototypes without the need to resort to external expertise.
Michael
To be completely honest, programming is one of the best things I have experienced. Truly. The combination of getting a chance to train your logic and making use of your own creativity is so very rewarding. And the almost endless number of applications you can put that knowledge into use is inspiring. I try to do at least 2 hours of programming every day, and it’s something I look forward to each time I get out of bed. Thanks for that Zed! Without your online course I wouldn’t have dared to take the leap.
Michael
I just completed the command line crash course and want to express my feeling towards your lessons and teaching methods. I have been learning all over the web about coding and very few places make me feel like I’m grasping the methods. I like how you “made” me make flash cards and things felt like a true bootcamp. I have learned a lot more about the command line and am not so afraid of it anymore. I wanted to ask if you have any JavaScript writings as I did not see any on your webpage, I will definitely be reading Ruby but JavaScript is really tripping me up in places and I could use better explanations for things than the ones I’ve seen.
Kevin
I’m reading your book, Learn Python the Hard Way, and really enjoying it. Your teaching approach is the best. I remember at the university, we would have to reach large and dense chapters on programming concepts before writing a line of code. It was insufferable. It should be the other way around, as you have recognized, writing code first and later reading as much about it as is necessary or desired. That deep understanding is important, but it’s really impossible to achieve through reading alone and must instead spring forth from a foundation of hands on experience.
Christopher
Thank you so much for the great resource you have provided in Learn C The Hard Way. To give you some positive feedback, I recently used your site to refresh my C skills from Uni, having not used them in anger for a number of years. At the conclusion I applied for work as a C \ Python developer. I feel as though I put my best foot forward, and my inner software engineer has gotten back its spark.
Anonymous
I just wanted to let you know that this course is awesome. I’m following all of the instructions and everything makes sense, so I don’t actually need help. I just wanted to thank you. This is a really well constructed course and well worth the very affordable expense. Cheers.
Nathan
I really appreciate what you have given back and I agree with your [writings]. You have helped my career tremendously. Thank you from the bottom of my fingers.
Anthony
I would like to thank you for writing your books. About 8 months ago I was ready to try something new. I had never done any programming before but I have a few friends and relatives who do it for a living and thought I would give it a try. I came across your books and got to work. The way your books are organized and how each chapter progressed in simple steps helped me a lot. I also appreciated your straight forward attitude and tone throughout. I just released my first iOS app for sale.
Greg
I recently finished LPTHW and greatly enjoyed it. Python’s readability and your teaching approach really helped me to finally overcome some mental obstacles to developing programming abilities that have frustrated me for a long time. I appreciate you making your knowledge available to the world for free. I found your ‘what to tell know-it-all programmers’ and general life observations just as interesting as the code.
Drew
Can I just say how grateful I am to you for writing this book. It is the first thing I have found that has made me feel like, I can get it together and learn to code.
Alexander