13 lessons · Python 3.14 runs in your browser · No account
Learn Python
Python is a general-purpose programming language that reads close to plain English, which makes it a common first language. Each lesson here is short, runs real code on the page, and ends with an exercise the page checks, then a quiz.
name = "World"
print(f"Hello, {name}!")Hello, World!
Every lesson looks like this. Edit the code, press Run, read the real output.
What you'll learn
1Getting started8 lessons
- 1. Hello World (finished)Write and run your first Python program. Print Hello, World! in your browser, see the real output, fix a broken version and take a short quiz.
- 2. Variables (finished)Learn what a Python variable is, how to create one, the rules for names, and how a variable changes value and type. Every example runs in your browser.
- 3. Data types (finished)The built-in Python data types, how to check a value's type with type(), how to convert between types, and which can change. Examples run in your browser.
- 4. Numbers (finished)How Python numbers work, with int and float, the seven arithmetic operators including floor division and modulo, why 0.1 + 0.2 is not 0.3, and rounding.
- 5. Strings (finished)How Python strings work, with quotes, indexing, slicing, the most useful methods, why strings never change, escapes and raw strings.
- 6. String formatting (finished)Format Python strings with f-strings. Put variables in text, show 2 decimal places, add thousands separators, align columns, and recognize %s and format().
- 7. Input and output (finished)Read what the user types with input(), turn it into a number, and control print() with end and sep, including how to print without a newline.
- 8. Comments (finished)Write Python comments with #, comment out several lines with one shortcut, learn why triple quotes are not comments, and add a docstring to a function.
2Making decisions4 lessons
- 9. Booleans and comparisons (finished)How Python booleans work, with True and False, the six operators that compare values, why True == 1, what bool() treats as False, and == versus is.
- 10. if, elif and else (finished)How if, elif and else work in Python, why elif exists, the one-line form, nested ifs, and the exact error messages a missing colon or indent produces.
- 11. Logical operators (finished)The logical operators and, or and not in Python, with a truth table, why && is an error, short-circuit rules, the values they return, and precedence.
- 12. match statement (finished)Python has no switch keyword, but since 3.10, match and case do the job. Learn case _, matching several values with |, guards, and why no break is needed.
Frequently asked questions
Is Python easy to learn?
Python is one of the easier languages to start with. Its syntax reads close to English, and you can try it without installing anything. Getting good at it still takes practice, which is why every lesson here has an exercise.
How long does it take to learn Python?
It depends on how often you practice. The lessons here are short enough that you can finish each one in a single sitting, and the basics stick fastest when you also write small programs of your own.
Can I learn Python on my own for free?
Yes. This course is free, needs no account, and runs in your browser. The official tutorial at docs.python.org is a good companion to it.
Do I need to install anything to follow along?
No. A copy of Python runs inside your browser, so every example works without installing anything. Install Python when you want to run programs outside the browser, and the Installing Python lesson shows how on Windows, macOS and Linux.
Is my progress saved?
Yes, in your browser on this device, with no account. Answer every quiz question in a lesson and that lesson gets a check mark wherever the course lists it. Clearing site data resets your progress, and it does not carry over to another browser or device.
Which version of Python does this course use?
Python 3.14. The examples run in that same version, so the output on the page matches Python 3.14 on your computer, apart from file paths in error messages and the text you type at an input() prompt, which the page does not echo.