Beginner resources
Basic programming can take months/years to get comfortable with (unless you take to programming like fish in water). Many a times, you'll need to go through lessons again and again. Programming requires hands-on experience too, do manually follow along the examples on your computer, don't just read/watch them. As an analogy, can you learn to drive a car by reading about it and/or watching videos alone? How about physical fitness exercises, can you achieve that by reading? I'd also highly recommend reading this article: How to teach yourself hard things.
Solving practice problems is very useful to review your understanding. After familiarizing with basics, doing your own project is highly recommended. If you get stuck, you can search online/documentation/books for those specific problems, and if that fails, you can ask for help on forums.
New to programming
Books:
- Think Python — gives you a solid foundation to programming, teaches debugging right the beginning, interesting exercises, etc
- The Python Coding Book — friendly, relaxed programming book for beginners
- Automate the Boring Stuff with Python — teaches you programming concepts and then shows how to automate everyday problems
- Python Crash Course — teaches you programming concepts and then goes through projects on games, data visualization and web applications
Interactive websites:
- futurecoder — includes integrated debuggers, enhanced tracebacks, hints for exercises and more
- Foundations of Python Programming — project based course
- PyFlo — interactive beginners guide to becoming a Python programmer
- scrimba: Learn Python — tutorials and interactive coding challenges
- Learn Python with Reeborg — students are given tasks that Reeborg has to complete, and they must write programs instructing Reeborg how to do so
New to Python
- Official Python docs tutorial — comprehensive guide
- 100 Page Python Intro — my short, introductory guide
- Python 101 — teaches Python syntax, followed by how to create prototype applications and binaries
- A Whirlwind Tour of Python — fast-paced introduction to essential components of the Python language
- learnxinyminutes post for Python — cheatsheet with explanations
Courses with certificates
- Python Programming — provided by University of Helsinki, introduction to Programming with Python, includes both text and video materials
- Harvard CS50's Introduction to Programming with Python — self paced free OpenCourseWare
- MIT: Introduction to Computer Science and Programming Using Python — self paced free course on edx
Exercises
If you feel comfortable with programming basics and Python syntax, then exercises are a good way to test your knowledge. The resource you used to learn Python will typically have some sort of exercises, so those would be ideal as a first choice. I'd also suggest using the below resources to improve your skills. If you get stuck, reread the material related to those topics, search online, ask for clarifications, etc — in short, make an effort to solve it. It is okay to skip some troublesome problems (and come back to it later if you have the time), but you should be able to solve most of the beginner problems. Maintaining notes will help too, especially for common mistakes.
- Exercism, Hackinscience and Practicepython — these are all beginner friendly and difficulty levels are marked
- Python Exercises — my interactive TUI app, suited for beginner to intermediate level Python learners
- Python Programming Exercises, Gently Explained — includes gentle explanations of the problem, the prerequisite coding concepts you'll need to understand the solution, etc
- Adventofcode, Codewars, Python Morsels — includes more challenging exercises for intermediate to advanced level users
- Checkio, Codingame, Codecombat — gaming based challenges
- /r/dailyprogrammer — not active currently, but there's plenty of past challenges with discussions
Projects
Once you are comfortable with basics and syntax, the next step is projects. I wrote a 10-line program that solved a common problem for me — adding body { text-align: justify }
to epub
files that are not justify aligned. I didn't know that this line would help beforehand. Found a solution online and then automated the process of unzipping epub
, adding the line and then packing it again. That will likely need you to lookup documentation and go through some stackoverflow Q&A as well. And once you have written the solution and use it regularly, you'll likely encounter corner cases and features to be added. I feel this is a great way to learn and understand programming.
These days, I use a better EPUB reader that allows me to customize alignments. Here's another real world example. I'm on Linux and use the terminal for many things. I wanted a CLI tool to do simple calculations. There's bc
command, but it doesn't accept direct string argument and you need to set scale
and so on. So, I looked up how to write a CLI tool in Python and wrote one using the built-in argparse
module that works for my particular use cases.
- Practice Python Projects — my book on beginner to intermediate level projects
- Projects with solutions — algorithms, data structures, networking, security, databases, etc
- Project based learning — web applications, bots, data science, machine learning, etc
- Pytudes by Peter Norvig — Python programs, usually short, of considerable difficulty
- Python Projects You Can Build
- Books:
- The Big Book of Small Python Projects
- Projectbook — collection of over 100 software project ideas for people looking to learn a given language or technology
- Tiny Python Projects
- Practical Python Projects
- Impractical Python Projects and Real world Python
- /r/learnpython: What do you automate with Python at home?
- Rosettacode
See also:
- How to Plan and Build a Programming Project
- Somepackage — Shows how to structure a Python project
- The Good Research Code Handbook — how to organize your code so that it is easy to understand and works reliably (aimed at researchers)
Debugging
Knowing how to debug your programs is crucial and should be ideally taught right from the beginning instead of a chapter at the end of the book. Think Python is an awesome example for such a resource material.
Sites like Pythontutor allow you to visually debug a program — you can execute a program step by step and see the current value of variables. Similar feature is typically provided by IDEs like Pycharm and Thonny. Under the hood, these visualizations are using the pdb module. See also Python debugging with pdb.
Debugging is often a frustrating experience. Taking a break helps (and sometimes I have found/solved the problem in my dreams). Try to reduce the code as much as possible so that you are left with minimal code necessary to reproduce the issue. Talking about the problem to a friend/colleague/inanimate-objects/etc can help too — known as Rubber duck debugging. I have often found the issue while formulating a question to be asked on forums like stackoverflow/reddit because writing down your problem is another way to bring clarity than just having a vague idea in your mind. Here's some more articles on this challenging topic:
- What does debugging a program look like?
- Debugging Python code is like detective work
- How to debug small programs
- Debugging guide
- Problem solving skills
Here's an interesting snippet (modified to keep it small) from a collection of interesting bug stories.
A jpeg parser choked whenever the CEO came into the room, because he always had a shirt with a square pattern on it, which triggered some special case of contrast and block boundary algorithms.
See also curated list of absurd software bug stories.
Tools, IDE and Text Editors
- Pythontutor: Visualize code execution — also has example codes and ability to share sessions
- Thonny — Python IDE for beginners, lots of handy features like viewing variables, debugger, step through, highlight syntax errors, name completion, etc
- Pycharm — smart code completion, code inspections, on-the-fly error highlighting and quick-fixes, automated code refactorings, rich navigation capabilities, support for frameworks, etc
- Spyder — scientific environment
- Jupyter — web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text
- VSCodium — community-driven, freely-licensed binary distribution of VSCode
- Vim, Emacs, Geany, GNOME Text Editor — text editors with support for syntax highlighting and other features
Cheatsheets
Maintaining your own cheatsheet as you learn is recommended, which you can complement with these resources.
- Python Crash Course cheatsheet
- Comprehensive Python cheatsheet
- Scientific Python cheatsheet
- Common beginner errors — use the pdf link
- Python regular expression cheatsheet — my blog post, includes examples as well
Documentation and getting help
The offical Python website has an extensive documentation located at https://docs.python.org/3/. This site has a search functionality, includes a tutorial, several guides for specific modules like re
, argparse
and various other information.
If you get stuck with a problem, there are several ways to get it resolved. For example:
- read/search for that particular topic from documentation/books/tutorials/etc
- reduce the code as much as possible so that you are left with minimal code necessary to reproduce the issue
- talk about the problem with a friend/colleague/inanimate-objects/etc (see Rubber duck debugging)
- search about the problem online
You can also ask for help on forums. Make sure to read the instructions provided by the respective forums before asking a question. See also How to get useful answers to your questions. Here are some forums you can use:
- /r/learnpython and /r/learnprogramming/ — beginner friendly
- python-forum — dedicated Python forum, encourages back and forth discussions based on the topic of the thread
- /r/Python/ — general Python discussion
- stackoverflow: python tag