Complete beginner course

Python Programming Tutorials

Thirteen modules that take you from installing Python to writing classes, in the order the topics actually build on each other. Every module links to worked tutorials with real code and real output.

  • 13 modules
  • 790+ tutorials
  • 6 weeks part time
hello.py
1# your first Python program
2name = input("What is your name? ")
3print(f"Hello, {name}!")
OutputWhat is your name? Bijay Hello, Bijay!
Three lines, and you are programming. Run it yourself

First, the why

What Python Is, and Why Learn It

Python is a general-purpose programming language designed to be read easily by people, not just executed quickly by machines. It runs on Windows, macOS and Linux, it is free, and it has been around since 1991 — so nothing you learn here is a passing trend.

Readable enough to learn first

Python reads close to English, which is why it is the most common first language in universities and bootcamps. if age > 18: means what it looks like it means. That readability is not just a beginner convenience either: it is the reason teams pick Python for code that has to be maintained by whoever arrives next.

It goes everywhere

The same language handles data analysis, machine learning, web backends, automation scripts, desktop tools and testing. Learning it once opens all of those doors, and you can change direction later without starting again with a new language.

The libraries do the hard part

Whatever you are building, somebody has already written and tested most of it. NumPy, Pandas, Django and the rest mean you write the part that is specific to your problem rather than the plumbing underneath it.

Employers are still hiring for it

Python appears consistently near the top of language demand surveys, and it is the default in data science and machine learning. That is worth knowing if the reason you are learning is a job rather than curiosity.

Installing on Windows

Download the installer from python.org and run it. The one thing that matters on the first screen is the Add Python to PATH checkbox at the bottom — tick it. Skipping it is the single most common setup mistake, and it produces the 'python' is not recognized message that sends people back to the search bar. Check it worked by opening a new Command Prompt and running python --version.

Installing on macOS

macOS ships with an old Python that exists for the system’s own use, so install a current one rather than relying on it. Either download the official installer or use Homebrew with brew install python. Afterwards, python3 --version should report 3.x. On macOS you will usually type python3 and pip3 rather than python and pip.

Installing on Linux

Most distributions already include Python 3. Run python3 --version to see what you have, and install it through your package manager if it is missing — sudo apt install python3 python3-pip on Debian or Ubuntu. Leave the system Python alone and use a virtual environment for your own projects, because other parts of the operating system depend on it.

Choosing an editor

Two sensible choices. VS Code is free, fast and handles every language, so it is the one to pick if you expect to write anything other than Python; add the Python extension and you are done. PyCharm knows more about Python out of the box, with stronger refactoring and a built-in debugger, at the cost of being heavier. Either is fine. Spend ten minutes learning to run a file and set a breakpoint, then stop thinking about it.

Three lines, explained

Your First Python Program

The program in the panel at the top of this page is worth pulling apart, because those three lines already contain four ideas you will use in everything else.

The comment

The first line starts with #, so Python ignores it completely. Comments exist for whoever reads the code next, which is usually you in three months. Writing them for the why rather than the what is the habit worth forming: the code already says what it does.

The variable

name = input("What is your name? ") does two things at once. It prints the question, waits for you to type, and stores whatever you typed in a box labelled name. No type is declared anywhere, because Python works out that this is a string on its own.

The function call

input() and print() are both functions: named blocks of code somebody else wrote that you use by calling them. The brackets are how you call one, and anything inside the brackets is what you are handing it to work with.

The f-string

f"Hello, {name}!" builds a new string with the value of name dropped into the middle. The f before the quote is what makes the braces work. You will use this constantly, and it is the clearest of the several ways Python offers to combine text and values.

The syllabus

Thirteen Modules, In Order

Work through them top to bottom. Each one assumes the ones above it, which is why skipping ahead is the usual reason people get stuck.

  • 1

    Syntax and comments

    Week 1

    How Python code is laid out, and why indentation is not optional.

    Python uses indentation where most languages use curly braces, so the shape of your code is the code. That feels strict for about a day and then becomes the reason Python is readable. This module is short, but getting it wrong produces the IndentationError that stops most first programs.

    • Indentation instead of curly braces
    • Statements, expressions and blocks
    • Single-line and block comments
    • Naming things the way Python expects
  • The handful of types almost every program is built from.

    Python works out the type for you, which is convenient right up to the moment you try to add a number to a string and get a TypeError. Knowing which type you are holding, and how to convert between them deliberately, prevents most beginner bugs. There are only a few types to learn and you will use all of them constantly.

    • Integers, floats, strings and booleans
    • Checking a type with type()
    • Converting between types on purpose
    • Where None fits in
  • 3

    Strings

    Week 1

    Text handling, which is most of what real programs do.

    Almost everything arriving from a file, a form or an API is text, so string handling is not a side topic. Slicing, splitting, joining and formatting come up in every project, and f-strings in particular will appear in nearly every line you write that produces output.

    • Slicing, indexing and looping over text
    • f-strings and formatting numbers
    • Splitting, joining and replacing
    • Searching for substrings
  • 4

    Operators

    Week 1

    Arithmetic, comparison and logic, including the ones that surprise people.

    Most operators do exactly what school maths taught you, with two exceptions worth meeting early: / always produces a float even when both sides are whole numbers, and == compares values while is compares identity. Getting those two straight now saves a confusing hour later.

    • Arithmetic, and why / always gives a float
    • Comparison operators and chaining them
    • and, or, not
    • Membership with in
  • Making decisions and repeating work, the two halves of control flow.

    This is the module where you stop writing scripts that run top to bottom and start writing programs that react. Conditionals choose a path, loops repeat work, and between them they cover most of what any program does. Give this one a full week even if it looks short, because everything afterwards assumes it.

    • if, elif and else
    • for loops and range()
    • while loops and when they hang
    • break, continue and pass
  • 6

    Functions

    Week 3

    Packaging work so you write it once and call it everywhere.

    A function turns a block of code into something with a name you can call from anywhere, which is where programs stop being long and start being organised. Parameters, return values and default arguments are the core, and understanding what a function can and cannot see from outside itself is the concept that takes longest to settle.

    • Defining, calling and returning
    • Default arguments and keyword arguments
    • *args and **kwargs
    • Lambda functions and where they belong
  • 7

    Lists

    Week 3

    The workhorse container, and the one you will reach for most.

    Lists hold an ordered, changeable collection of anything, and they are the container you will use more than all the others combined. Slicing and comprehensions are the two features worth real practice, because a comprehension replaces four lines of loop with one readable line once it clicks.

    • Adding, removing and slicing
    • Sorting and reversing
    • List comprehensions
    • Copying without sharing the same list
  • 8

    Dictionaries

    Week 3

    Key-value data, which is how most real information is shaped.

    A dictionary stores values against keys rather than positions, which matches how real data is actually organised: a user has a name and an email, not a first and second thing. Every JSON response you ever parse becomes a dictionary, so this module pays for itself the first time you call an API.

    • Adding, updating and removing keys
    • Looping over keys, values and items
    • Nested dictionaries
    • Handling a missing key safely
  • 9

    Tuples and sets

    Week 3

    The two containers people skip, and then need.

    A tuple is a list that cannot change, which makes it safe to pass around and usable as a dictionary key. A set holds unique items and answers is this in here? almost instantly, however large it gets. Neither is exotic, and knowing when to use one instead of a list is a genuine mark of progress.

    • Tuples: fixed, hashable, unpackable
    • Sets: uniqueness and fast membership
    • Set maths: union, intersection, difference
    • Choosing between list, tuple, set and dict
  • 10

    Arrays

    Week 4

    Python’s array types, and the moment you should switch to NumPy.

    Python has an array module, but in practice a list covers most needs until the data gets large or numeric, at which point NumPy takes over entirely. The useful outcome of this module is knowing which of the three you are looking at in someone else’s code and why they chose it.

    • Lists versus the array module
    • When a list stops being fast enough
    • Two-dimensional data
    • Where NumPy takes over
  • 11

    File handling

    Week 4

    Reading and writing real files instead of hard-coded values.

    This is the module where your programs start working on real data rather than values you typed in yourself. Always open files with with, which closes them even if something fails halfway, and expect encoding to cause at least one confusing error the first time you read a file somebody else produced.

    • Opening files with with
    • Reading whole files and line by line
    • Writing and appending
    • CSV and text, and why encoding matters
  • 12

    Exception handling

    Week 4

    Programs that fail usefully instead of crashing.

    Real input is missing, malformed or absent, and a program that stops dead on the first surprise is not finished. Catching the specific exception you expected is the skill here; a bare except that swallows everything hides the bug you needed to see. Learning to read a traceback from the bottom up is worth the module on its own.

    • try, except, else, finally
    • Catching the right exception, not all of them
    • Raising your own
    • Reading a traceback properly
  • Classes and objects, which is where Python code starts to scale.

    A class bundles data and the functions that work on it into one thing you can create many of. It is the concept beginners find hardest and the one that makes larger programs possible, so take two weeks rather than one. Once classes click, a great deal of other people’s code stops looking mysterious.

    • Classes, objects, attributes and self
    • __init__ and constructors
    • Inheritance and super()
    • Encapsulation and the four pillars

Once the thirteen are done

Three More Worth Learning

Not strictly beginner material, but all three come up quickly in real projects.

  • Modules and packages

    Import the standard library, install with pip, and split your own code into files.

  • Regular expressions

    Pattern matching for text that split() cannot handle.

  • Recursion

    Functions that call themselves, and when that is the clear solution.

The whole plan

Your Six-Week Learning Path

Based on roughly an hour a day. Faster if you have more time, and slower is completely fine — the order matters far more than the pace.

StageWhenWhat you coverWhat you can do after
Set upDay 1Install Python, PATH, an editor, Hello WorldA program that runs on your machine
Modules 1–4Week 1Syntax, data types, strings, operatorsRead and write basic Python
Modules 5–6Weeks 2–3Conditionals, loops, functionsSolve small problems on your own
Modules 7–10Weeks 3–4Lists, dictionaries, tuples, sets, arraysChoose the right container
Modules 11–12Week 4Files and exception handlingWork with real data, fail safely
Module 13Weeks 5–6Object-oriented programmingStructure a larger program
NextWeek 7+Pick a library trackBuild something people can use

After the basics

Then Pick a Direction

Core Python is the same for everyone. What you learn next depends entirely on what you want to build, so choose one track and finish it.

Common questions

Questions Beginners Ask

  • How long does it take to learn Python?

    About six weeks of steady part-time study to be comfortable with the thirteen modules here, at roughly an hour a day. Being employable takes longer, usually four to eight months including a specialisation and a couple of real projects. The people who get there fastest are the ones who build something small every week rather than reading ahead.

  • Do I need to be good at maths?

    No, not for general Python. You need arithmetic and a bit of logic, which you already have. Machine learning genuinely does want statistics and some linear algebra, but that is a later specialisation and you can learn the maths alongside it rather than before it.

  • Should I learn Python 2 or Python 3?

    Python 3. Python 2 reached end of life in 2020 and receives no updates at all. If you find a tutorial using print without brackets, it is written for Python 2 and you should find a newer one.

  • Which editor should I use?

    VS Code or PyCharm, and it matters much less than people suggest. VS Code is lighter and more general; PyCharm knows more about Python out of the box. Pick one, spend ten minutes learning to run a file and set a breakpoint, and move on.

  • Can I skip ahead to the topic I need?

    You can, and the modules are linked so it is easy. Be aware that each one assumes the ones above it, so if a tutorial suddenly stops making sense the gap is usually one or two modules back rather than in the page you are reading.

  • What should I build first?

    Something small and genuinely useful to you: a script that renames files, a program that reads a CSV and prints a summary, a number-guessing game. Finishing something tiny teaches far more than abandoning something ambitious, and you can only start once modules 1 to 6 are done.

One more thing

Reading Is Not Learning

Type every example out rather than copying it, and change something before you move on. The tutorials here all show real output so you can check your version against a run that actually happened.