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:

New to Python

Courses with certificates

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.

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.

See also:

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:

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.

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:

  1. read/search for that particular topic from documentation/books/tutorials/etc
  2. reduce the code as much as possible so that you are left with minimal code necessary to reproduce the issue
  3. talk about the problem with a friend/colleague/inanimate-objects/etc (see Rubber duck debugging)
  4. 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: