Python learning roadmap: from basics to real projects

Python is readable, versatile and in demand. Follow this path from first script to useful projects in web, data and automation.

A Python path leading to web, data and automation projects

Python is a popular language for beginners and professionals. Its readable syntax lets you focus on ideas, and it is used for scripting, web backends, data analysis, machine learning, automation and more. This roadmap shows an order to learn it.

Stage 1: the basics

  • Install Python and run code from a file and from the interactive prompt.
  • Variables and types: int, float, str, bool, None.
  • Operators, string formatting (f-strings) and user input.
  • Conditions: if, elif, else.
  • Loops: for, while, break, continue, and range.
  • Functions: parameters, default values, return values, scope.
def greet(name, excited=False):
    msg = f"Hello, {name}"
    return msg + "!" if excited else msg

print(greet("Rafi", excited=True))

Stage 2: data structures

  • Lists, tuples, dictionaries, sets and when to use each.
  • Slicing and comprehensions: [x * 2 for x in nums if x > 0].
  • Sorting, enumerate, zip.
  • Mutable vs immutable values, and the "copy vs reference" trap.

Stage 3: working with files and errors

  • Reading and writing text files with with open(...).
  • JSON and CSV using the standard library.
  • Exceptions: try, except, finally, and raising your own errors.
  • The pathlib module for paths.

Stage 4: organising code

  • Modules and packages, import, and if __name__ == "__main__":.
  • Virtual environments (python -m venv .venv) so each project has its own packages.
  • pip to install libraries, and a requirements.txt or pyproject.toml to record them.
  • Style: PEP 8, with tools such as a formatter and linter.
  • Type hints to document and check your code.

Stage 5: object-oriented and more advanced Python

  • Classes, methods, __init__, inheritance and composition. Prefer simple designs.
  • Dataclasses for simple data containers.
  • Generators and iterators, decorators, context managers.
  • The standard library: collections, itertools, datetime, re (regular expressions), argparse, logging.

Stage 6: testing and quality

  • pytest for tests. Write tests for the code you write.
  • Debug with print/logging and the built-in debugger.
  • Learn to read tracebacks from the bottom up.

Stage 7: choose a direction

Automation and scripting

  • Rename files, process spreadsheets, scrape pages politely, call APIs, send emails.
  • Libraries: requests or httpx, beautifulsoup4, openpyxl.
  • Respect websites' terms and robots rules when scraping.

Web backend

  • FastAPI, Flask or Django.
  • Databases with SQL, ORMs such as SQLAlchemy or the Django ORM.
  • Authentication, validation, deployment.

Data and analysis

  • NumPy, pandas, matplotlib, Jupyter notebooks.
  • Cleaning data, grouping, charts and simple statistics.

Machine learning and AI

  • Foundations first: maths basics and data handling.
  • scikit-learn for classic machine learning, then deep learning frameworks.
  • Calling LLM APIs and building apps with them (see the AI series).

DevOps and tools

  • Writing command-line tools, automating servers and cloud tasks.

Project ideas by level

  • Beginner: number guessing game, to-do list in the terminal, unit converter.
  • Intermediate: expense tracker saving to CSV or SQLite, a script that organises your downloads folder, a weather command-line app using a public API.
  • Advanced: a REST API with a database and tests, a data dashboard, a Telegram bot, a small web scraper with a scheduled job.

Habits that help

  • Code daily, even briefly, and build projects instead of only watching videos.
  • Read other people's code and the official docs (docs.python.org).
  • Use Git from the start.
  • Learn to search for errors and read documentation.
  • Do not skip fundamentals to reach machine learning fast. The basics carry everything.

Common mistakes

  • Installing everything globally instead of using virtual environments.
  • Mutable default arguments in functions (def f(x, items=[])), which are shared between calls.
  • Catching every exception silently.
  • Writing long scripts without functions or tests.
  • Using an outdated Python 2 tutorial. Use a current Python 3 resource.

Takeaway: learn the syntax and data structures, handle files and errors, use virtual environments and tests, then pick one direction (automation, web, data or AI) and build projects there.


Programming roadmaps series, Part 2 (languages and design): 1 of 5.

Keep reading