New: 6 free SQL practice datasets with 300+ questions — try the SQL Compiler →
Python

How to Learn Python: A Step-by-Step Roadmap

How to learn Python step by step: a seven-stage roadmap from variables to classes, files and errors, with a working example and checkpoint at each stage.

Upskly AI Team September 26, 2026 9 min read
How to Learn Python: A Step-by-Step Roadmap

The best way to learn Python is to learn it in a sensible order, type every example yourself, and build small things as you go. This guide is that order: a seven-stage roadmap from your first variable to classes, files and error handling, with a short working example and a checkpoint at each stage, so you know when you are ready to move on.

Each stage links to a detailed guide with real, run code. You do not need to install anything to follow along. You can run every example in our free Python compiler in your browser.

In this guide

The short version

  • Learn in order: basics, collections, loops, functions, how objects work, classes, then robust code.
  • Type the code yourself and change it. Reading alone does not stick.
  • Build a tiny program at the end of each stage. That is your checkpoint.
  • Read error messages from the bottom up. They usually tell you exactly what is wrong.

The 7 stages at a glance

A Python learning roadmap
StageWhat you learnDetailed guidesCheckpoint
1. BasicsVariables, numbers, text, True/FalseData Types, StringsConvert a temperature
2. CollectionsLists, tuples, sets, dictionariesList vs Tuple vs Set, DictionariesCount words in a sentence
3. Loopsfor, while, comprehensionsLoops, List ComprehensionSolve FizzBuzz
4. Functionsdef, arguments, return, scope, lambdaFunctions, *args and **kwargs, lambda/map/filterA function with a default value
5. How Python worksMutable objects, copying, generatorsMutable vs Immutable, Copying, GeneratorsExplain why b = a shares data
6. ClassesClasses, objects, inheritanceClasses and Objects, Inheritance and Dunder MethodsA small bank account class
7. Robust codeExceptions, files, with, decoratorsException Handling, Files, Context Managers, DecoratorsRead a file safely

Plan on roughly one to two weeks per stage if you practise most days. That is only a rough guide. The pace that works is the one you keep up.

Stage 1: Basics, types and strings

Start with the raw materials: numbers, text and true/false values, and how to store them in variables. Learn to print things, do arithmetic, and use f-strings to build messages. Do not rush past strings: text handling is most of real-world programming.

celsius = 37
fahrenheit = celsius * 9 / 5 + 32
print(f"{celsius} C is {fahrenheit:.1f} F")

Output

37 C is 98.6 F

Checkpoint: you can write a short script that takes a number, does a calculation and prints a formatted result, and you can explain the difference between int, float and str.

Read next: Python Data Types Explained With Examples and Python Strings: Methods and Slicing Explained.

Stage 2: Collections

Real programs work with groups of values. Learn the four core collections and which to use when: lists for ordered data that changes, tuples for fixed groups, sets for unique items, and dictionaries for looking things up by name. Dictionaries in particular are used everywhere in Python.

text = "to be or not to be"
counts = {}
for word in text.split():
    counts[word] = counts.get(word, 0) + 1
print(counts)
print(sorted(counts.items(), key=lambda kv: -kv[1])[0])

Output

{'to': 2, 'be': 2, 'or': 1, 'not': 1}
('to', 2)

Checkpoint: you can count how often each word appears in a sentence, and you can say why a dictionary is a better tool for that than a list.

Read next: Python List vs Tuple vs Set: Key Differences and Python Dictionaries Explained With Examples.

Stage 3: Loops and comprehensions

Now make your programs repeat and decide. Learn if/elif/else, for and while loops, range(), break and continue. Once loops feel natural, learn list comprehensions, the compact way to build a list from another.

result = []
for n in range(1, 16):
    if n % 15 == 0:
        result.append("FizzBuzz")
    elif n % 3 == 0:
        result.append("Fizz")
    elif n % 5 == 0:
        result.append("Buzz")
    else:
        result.append(n)
print(result)

Output

[1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz']

Checkpoint: you can solve FizzBuzz without looking, and you can rewrite a simple for loop that builds a list as a list comprehension.

Read next: Python Loops: for, while, break and continue and Python List Comprehension Explained Simply.

Stage 4: Functions

Functions turn a pile of code into reusable pieces. Learn parameters, default values, return versus print, and variable scope. Then look at how functions accept flexible arguments (*args and **kwargs) and how tiny lambda functions work with sorted, map and filter.

def grade(mark, pass_mark=40):
    return "pass" if mark >= pass_mark else "fail"

print(grade(72), grade(35), grade(35, pass_mark=30))

Output

pass fail pass

Checkpoint: you can turn any repeated block of your own code into a function, and you can explain what happens when a function has no return.

Read next: Python Functions: Arguments, Return and Scope, Python *args and **kwargs Explained and Python lambda, map, filter and reduce Explained.

Stage 5: How Python really works

This is the stage that separates people who copy code from people who understand it. Learn that variables are names for objects, which objects can change in place, why b = a does not copy, and how shallow and deep copies differ. Then meet generators, which produce values one at a time and save memory.

def squares(limit):
    for n in range(1, limit + 1):
        yield n * n

print(list(squares(5)))
print(sum(squares(1000)))

Output

[1, 4, 9, 16, 25]
333833500

Checkpoint: you can explain, with an example, why changing a list inside a function changes the caller’s list, and you can write a small generator with yield.

Read next: Mutable vs Immutable Objects in Python, Shallow Copy vs Deep Copy in Python and Python Iterators and Generators Explained.

Stage 6: Classes and objects

Classes let you bundle data and behaviour, which is how larger programs are organised. Learn __init__, self, methods and attributes first. Then move on to inheritance, super() and the special methods (such as __str__ and __len__) that make your objects work with Python’s built-in syntax.

class Account:
    def __init__(self, balance=0):
        self.balance = balance

    def deposit(self, amount):
        self.balance += amount
        return self.balance

acc = Account(100)
print(acc.deposit(50))

Output

150

Checkpoint: you can design a small class from scratch, such as a bank account, a to-do list or a student record, with a constructor and two or three methods.

Read next: Python Classes and Objects for Beginners and Python Inheritance and Dunder Methods Explained.

Stage 7: Writing robust programs

The last stage is about code that survives the real world: bad input, missing files, resources that must be cleaned up. Learn try/except/finally, how to read and write files, the with statement, and finally decorators, which add behaviour to functions without changing them.

def read_number(text):
    try:
        return int(text)
    except ValueError:
        return None

print([read_number(t) for t in ["10", "x", "7"]])

Output

[10, None, 7]

Checkpoint: you can read a text file, handle the case where it is missing or contains bad data, and never leave a file open.

Read next: Python Exception Handling: try, except, finally, Reading and Writing Files in Python, Python Context Managers and the with Statement and Python Decorators Explained Step by Step. When you finish, test yourself with 7 Python Gotchas That Trip Up Interviews.

How to practise

  • Type it, do not paste it. Typing forces you to notice every detail.
  • Change one thing and predict the result. Then run it. Being wrong is where the learning happens.
  • Build small programs. A number-guessing game, an expense tracker that saves to a file, a word-frequency counter, a to-do list class, or a script that summarises a log file. Each one uses several stages together.
  • Read your errors from the bottom up. The last line of a traceback names the error and usually the cause. The lines above show where it happened.
  • Practise little and often. Thirty focused minutes a day beats one long weekend session.

You can run all your practice code in our free Python compiler. If you get stuck on an error, AI Assist works inside the Python notebook, so you can ask about it without leaving the page.

Common beginner mistakes

  • Watching without typing. Tutorials feel productive, but you only learn what you write yourself.
  • Jumping to libraries too early. pandas and machine learning are much easier once loops, functions and dictionaries are second nature.
  • Ignoring error messages. Read them. They are trying to help.
  • Copying solutions you do not understand. If you cannot explain a line, take it apart until you can.
  • Never finishing a project. A small finished program teaches more than five abandoned big ones.
  • Skipping the object model. Mutable objects and copying cause the most confusing bugs. Stage 5 is worth the time.

Where to go after the core

With the core done, you can branch out depending on your goal:

  • Interviews and problem solving: data structures and algorithms in Python. Start with How to Learn DSA in Python: A Roadmap.
  • Data analysis: NumPy and pandas, which build directly on lists, dictionaries and functions.
  • Automation: scripts that handle files, spreadsheets and email.

Working with data often means SQL as well. Our roadmap for learning SQL is the companion to this one.

Frequently asked questions

How long does it take to learn Python?

It depends on how much you practise. With regular practice, many people are comfortable with the core language in a couple of months, and confident after building a few projects. The exact time varies from person to person.

What should I learn first in Python?

Start with variables, numbers, strings and printing, then lists and dictionaries, then loops and functions. The stages above put them in a workable order.

Do I need to know maths to learn Python?

Not for the core language. Basic arithmetic is enough to start. Maths matters later for data science and machine learning, and you can learn it when you get there.

Is Python good for beginners?

Yes. Its syntax reads close to plain English, you do not need to declare types, and you can see results immediately, which makes it easy to experiment and learn from your mistakes.

Should I learn Python or SQL first?

Both are useful for data work, and neither blocks the other. Many people start with SQL because its small set of commands gives quick wins, then add Python. Choose the one that matches the job you are aiming for, and learn the other soon after.

Can I learn Python without installing anything?

Yes. You can write and run Python in an online compiler such as ours, right in your browser, and install Python on your own computer later when you want to build larger projects.

Run this code in your browser

The free Upskly compiler runs Python with nothing to install. Paste the example, change it and see what happens.

Open Python Compiler

Stuck on a traceback?

AI Assist works inside the Python notebook, so you can ask about an error or a concept without leaving the cell.

Try AI Assist

Test yourself

Timed questions with an explanation for every answer.

Take the Quiz
Upskly AI Team
Learning made simple
Scroll to Top