What Python is
Python is a general-purpose language designed to read almost like English: blocks are marked by indentation rather than braces, and most everyday tasks take a handful of lines. It is interpreted, so you run a file directly without a separate compile step, and it comes with a large standard library for files, text, dates, maths and the web. That combination is why it is the usual first language in schools and the default language of data analysis, automation and machine learning.
Where Python is used
- Data analysis and machine learning
- Libraries such as pandas, NumPy, scikit-learn and PyTorch are Python-first, which is why most data and AI teams write their day-to-day code in it.
- Automation and scripting
- Renaming a thousand files, filling a spreadsheet from a website, or sending a daily report are short Python scripts, and the standard library covers most of it without installing anything.
- Web backends
- Django, Flask and FastAPI power the server side of many web applications and APIs.
- Teaching and prototyping
- Because an idea can be tried in a few lines, Python is where many programs are first sketched, even when they are later rewritten in something faster.
- Testing and tooling
- Build scripts, test harnesses and developer tools at many companies are Python, regardless of what the main product is written in.
Your first Python program
Saved as hello.py. You can paste it straight into the playground to see it run.
name = "Asha"
year = 2026
print("Hello, " + name + "!")
print(f"In five years it will be {year + 5}.")What it prints
Hello, Asha!
In five years it will be 2031.- Line 1 stores the text "Asha" under the name
name. Anything in quotes is text (a string); no type has to be declared. - Line 2 stores the whole number 2026 under
year. Python works out that it is a number from the way it is written. - Line 4 prints a line. The
+joins pieces of text end to end, so the pieces on either side of it must all be text. - Line 5 uses an f-string: the
fbefore the quote lets you put an expression inside curly braces, andyear + 5is worked out and dropped into the sentence.
Run Python on your own computer
You can run every Python example on this site in the browser playground with nothing installed. When you want Python on your own machine, the official installer is a five-minute job.
Install Python 3
Download the current 3.x release from python.org for Windows or macOS (on Windows, tick "Add python.exe to PATH" in the installer). Most Linux distributions already have it; otherwise install the python3 package with your package manager.
Check it works
Open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS/Linux) and ask for the version. Any 3.x version is fine for everything on this site.
Shellpython3 --versionSave a file and run it
Put the first program above in a file called hello.py, then run it from the folder it is in. On Windows the command is usually python rather than python3.
Shellpython3 hello.pyUse an editor with Python support
Any text editor works. VS Code with the official Python extension gives you error underlining, formatting and a Run button, and is free.
A learning order for Python
Stages, not a timetable. Each one exists because the next would not make sense without it, and how long each takes depends on how much you write.
Stage 1. Output, variables and arithmetic
- print()
- variables and assignment
- numbers and text
- f-strings
- input()
Everything else is built on being able to store a value and show it. This is also where the exercise path on this site starts, so you can do it entirely in the browser.
Stage 2. Decisions and repetition
- if / elif / else
- comparisons and booleans
- for loops and range()
- while loops
- break and continue
Programs become useful the moment they can choose and repeat. Loops are also where most early bugs live, which is why they deserve a slow, deliberate pass.
Stage 3. Collections
- lists and indexing
- slicing
- dictionaries
- tuples and sets
- loops over collections
- list comprehensions
Real data arrives in bulk. Knowing which structure to reach for — a list for order, a dictionary for lookup by name — is most of what separates clumsy code from clear code.
Stage 4. Functions and structure
- def and return
- parameters and default values
- scope
- modules and import
- the standard library
Once a program passes about fifty lines, it needs to be broken into named pieces. Functions are how, and modules are how those pieces are shared between files.
Stage 5. Errors, files and the outside world
- reading tracebacks
- try / except
- opening and writing files
- working with JSON and CSV
- installing packages with pip
Programs that touch the real world fail in real ways: a missing file, a bad line of data. Handling that gracefully is the difference between a script and a tool someone else can use.
Stage 6. Classes and beyond
- classes and objects
- methods and attributes
- testing with pytest
- virtual environments
- a first project of your own
Classes let you model things — an account, a player, an order — rather than juggling loose variables. From here the road forks toward data work, web backends or automation, and each has its own libraries to learn.
Mistakes beginners make in Python
- Mixing tabs and spaces, or indenting inconsistently
- In Python, indentation is the syntax that says which lines belong to an if or a loop. An extra space, or a tab where the editor used spaces elsewhere, is a real error (IndentationError), not a style problem. Set your editor to insert four spaces for Tab and the issue disappears.
- Adding a number to a string
- "Age: " + 30 stops with TypeError, because Python will not silently turn a number into text. Either convert it with str(30) or use an f-string, f"Age: {30}", which is what most Python code does.
- Expecting range(1, 5) to include 5
- The stop value is left out, so range(1, 5) gives 1, 2, 3, 4. That is consistent with lists starting at position 0, but it catches almost everyone once. Use range(1, n + 1) when you want to reach n.
- Changing a list while looping over it
- Removing items from a list inside a for loop over the same list skips elements, with no error to warn you. Build a new list of the items you want to keep instead.
- Comparing with = instead of ==
- A single = assigns; two == compare. Inside an if, a single = is a syntax error, which is helpful; but the habit is worth fixing early because in some other languages it is silently accepted.
Strengths and trade-offs
Where it is strong
- Readable syntax with little punctuation, so a beginner's attention goes to the logic rather than the brackets.
- A very large standard library and package ecosystem: most tasks have a well-maintained library already.
- Interactive by nature — you can type a line into the Python prompt and see the result, which makes experimenting cheap.
- The default language of data, scientific and machine-learning work, so what you learn here transfers directly to those fields.
Where it is not
- Slower than compiled languages such as C++, Java, Go or Rust for CPU-heavy work; performance-critical parts are usually written in another language and called from Python.
- Not the language for mobile apps or for code that has to run in a web page — that is Kotlin/Swift and JavaScript territory.
- Dynamic typing means some mistakes only show up when the line runs. Type hints and tools like mypy help, but they are optional.
- Package and environment management (pip, virtual environments) confuses many beginners the first time they need a library that is not built in.
Who Python is for
Python is the right first language for almost everyone, and the right next language for anyone heading into data, automation, scientific work or AI. If your goal is specifically iPhone or Android apps, or code that runs inside a web page, you will use Python less — but the concepts you learn here are the same ones those languages use.
Questions about learning Python
- Is Python good for a complete beginner?
- Yes. Its syntax is closer to plain English than most languages, you can run a program without a separate compile step, and errors point at the line that failed. That is why it is the most common first language in schools and universities, and why this site's Python exercises begin with a single print statement.
- Python 2 or Python 3?
- Python 3, always. Python 2 stopped receiving updates in 2020, and every tutorial, library and job today means Python 3 when it says Python. If a resource shows print "hello" without brackets, it is out of date.
- Do I need to install anything to try it?
- Not on this site. The playground and every exercise run real Python (CPython compiled to WebAssembly) inside your browser, and your code never leaves your computer. Install Python locally when you want to work with your own files or libraries.
- How long does it take to learn Python?
- There is no honest number; it depends on what you want to build and how much you practise. What can be said is that the basics in the roadmap above — variables, conditions, loops, collections, functions — are a matter of weeks of regular practice, and everything after that is learned by building things you actually want.
The primary source
When this guide and the official documentation disagree, the documentation is right and we would like to hear about it.