Why do so many developers choose Python instead of an older, faster, or stricter language? The answer is simple. Python makes writing code fast and easy, because it spends most of its effort on the person writing the code. That is a good trade whenever you are the slow part of the work. This lesson explains what Python is, how it runs your code, where it works well, where it costs you something, and how to decide if it fits your problem.
This is the first lesson in the Python Setup and First Program module, and the next lesson in this module is about "Installing Python 3.12 on Windows, macOS and Linux".
What is Python, in plain terms?
Python is a high-level, general-purpose programming language that uses dynamic typing. Guido van Rossum released the first version of it in 1991. Its main design goal was simple: code should read almost like the sentence you would say out loud. The language is also small enough that a beginner can learn the whole core in a few weeks. That is why Python has no semicolons, no curly braces, and no long public static void main header.
Six properties shape how you write Python every day:
- Indentation is part of the syntax. Indentation, not braces or keywords, shows which lines belong together. The usual rule is four spaces per level, and almost every tool expects that.
- Dynamic typing. Every value has a type while the program runs, and a variable is just a name that points at an object. You do not declare types first, so you can write a small idea and test it in seconds.
- Everything is an object. Numbers, functions, and classes are all objects with attributes and methods. Because every value works the same way, separate libraries fit together cleanly.
- Many things come built in. The standard library already has a JSON parser, a CSV reader, date tools, a queue, an email client, and an HTTP client. You can use all of them without installing anything.
- Memory is handled for you. You rarely free memory by hand, because Python collects objects that nothing is using any more.
- It runs on every major system and it is free. The same code runs on Windows, macOS, and Linux, and the Python Software Foundation looks after the language.
import sys
print('Python version:', sys.version)
# Every value has a type. You can ask for it with the type() function.
values = [42, 3.14, 'forty-two', True, None, [1, 2, 3]]
for value in values:
print(value, 'is a', type(value).__name__)
That loop shows the usual Python style. Take a list, go through it one item at a time, and print the result. There is no type to declare, no counter to update by hand, and no separator string to get wrong. If you want to see the exact text form of a value, wrap it in repr(). It shows quotes around strings, which is useful while you are debugging.
Is Python compiled or interpreted?
The honest answer is that it does both. When CPython starts, and CPython is the version almost everyone installs, it reads your source file and turns it into an intermediate form called bytecode. A virtual machine inside the interpreter then runs that bytecode. Python saves the bytecode in a .pyc file inside a __pycache__ folder next to your source file, so it only does this work again when the file changes.
This gives you three practical things to remember. Startup is a little slower than running a compiled binary, because the translation happens at least once. Deleting the __pycache__ folder is always safe, because it is only a cache and never the real source. And if you send your program to a computer without Python, you must install Python there or package it with a tool such as PyInstaller, which makes a much bigger file.
You can also look at the bytecode while you learn. It is a good way to understand a bug quickly, because Python can show you the exact steps it plans to take.
import dis
def add(a, b):
return a + b
# Ask Python to print the instructions it runs for this function.
dis.dis(add)
The output is short because the function is short: a marker to resume, two loads, one addition, and a return. Seeing LOAD_FAST and BINARY_OP behind a line that looks like plain arithmetic reminds you that the readable syntax you write is a translation step, not the final plan the computer follows.
What makes Python programs so short?
The short code comes from doing more work with fewer language features, not from a clever syntax. A few features let you write one whole idea on a single line where other languages need four or five lines. You will meet multiple assignment, sequence unpacking, and dictionary unpacking in your first few weeks, and they are the ones you will use every day.
# Swap two values without needing a temporary variable.
left, right = 'first', 'second'
left, right = right, left
print(left, right)
# Unpack a list into named parts. The name with * collects everything else.
head, *middle, tail = [10, 20, 30, 40, 50]
print('head:', head, 'middle:', middle, 'tail:', tail)
# Merge two dictionaries with ** instead of setting the keys one by one.
defaults = {'retries': 3, 'timeout': 30}
overrides = {'timeout': 10}
settings = {**defaults, **overrides}
print(settings)
None of this exists only to look neat. You will see the same pattern in the standard library and in popular packages. A function takes an options dictionary, merges your choices over the sensible defaults, and hands you back one dictionary that the rest of the program can read without extra checks.
Where does Python win, and where does it cost you?
Python is at its best when you spend much more time writing and reading code than you spend waiting for it to run. It is at its worst in the opposite case. The table below shows the usual pattern for each kind of work.
| Area | Why Python fits | Where it strains |
|---|---|---|
| Data analysis and machine learning | The libraries are the reason, because arrays, data frames, plotting, and model training all speak one language | Running models in production often moves to a faster runtime anyway |
| Web APIs and backends | Async frameworks, type hints, and small deployments | Raw request throughput is lower than compiled servers |
| Automation and operations | Shell scripts become real programs with error handling and tests | Long jobs that run with nobody watching need more care |
| Teaching and scripting | Very little setup keeps the lesson on the idea itself | Learners can carry careless habits forward |
| Embedded and hard real-time work | Almost never the right tool for the job | There is no fixed delay and no memory limit you can rely on |
Two costs surprise people who arrive from compiled languages. A Python loop is much slower than the same loop in C or Rust, because the interpreter carries out every step of the iteration itself. When that matters, the answer is not cleverer Python code but moving the heavy work into a vector library or a compiled extension. The second cost is that Python checks types while the program runs, so a mistake appears when the wrong line runs and not when the program starts. Type hints, a checker such as mypy, and a test suite close that gap.
There is also a setup cost when you deploy. The machine that runs your program needs a Python interpreter installed on it, and although packaging interpreters has improved, that cost has not gone away.
Where does Python sit in the 2026 toolchain?
The old question of Python 2 versus Python 3 is finished. Python 2 reached the end of its life in 2020, and the 3.x line is the only one you will meet in new work. Three releases matter today: version 3.12 arrived in October 2023, version 3.13 in October 2024, and version 3.14 in October 2025. So in 2026 the 3.14 series is the newest stable branch, while 3.12 and 3.13 are still used widely. Everything in this tutorial runs the same way on all three.
The recent releases mostly made Python safer to build on. Type parameter syntax means generic classes no longer need a separate typing import. F-strings can now use the same quote character that surrounds them, and they can run over more than one line. Error messages name the value that caused the problem more often. There is also an experimental build that removes the global interpreter lock, which helps CPU-heavy threading, but you have to ask for it and it is not the default. The tools around the language have grown up as well, with fast installers, one standard lock file format, and type checkers that run inside ordinary editors.
None of that changes the main deal. You give up a small amount of running speed and you get back a large increase in how much you finish each hour, and that is a good trade whenever you are the slow part of the work.
Your turn: check the Python you already have
You can learn a great deal about your own setup in about five minutes, and it is worth doing now because the next lesson builds on the result.
- Open a terminal. On Windows run
python --version, orpy --versionif you installed the launcher. On macOS and Linux runpython3 --version. Write down the exact number, because that is the version every command in this tutorial assumes. - Create a file named
orientation.pyand copy the first code block from this page into it. Then run it withpython orientation.py. - Add two more lines to the script. Print the sum of the numbers from 1 to 100, first with a loop and then with
sum(range(1, 101)). Both of them must print 5050. - Break the script on purpose. Put the text
'5'where the code expects the number 5 in the sum line, run it again, and read the error message from the bottom line upwards. That error message is the subject of the next lesson.
What to remember
- Python is dynamically typed, it uses indentation to show blocks, and it handles memory for you. Its standard library covers most of what a small program needs.
- CPython compiles your code to bytecode and saves it, so "interpreted" is a simplification, but a useful one when you estimate startup time.
- Short code comes from a few features doing more work each, not from a tricky syntax.
- Python wins when writing and reading code take most of the time, and it loses when raw speed and fixed delays matter most.
- The versions that matter in 2026 are 3.12, 3.13, and 3.14, and everything here runs on all three.