Free lesson · Python Basic to Advance
What Python Is
What Python Is and Why It Matters
What Python Is
Python is a high-level, general-purpose programming language. It runs on most operating systems, supports multiple programming paradigms (procedural, object-oriented, functional), and emphasizes code readability through significant whitespace and a deliberately small set of language constructs.
The language was created by Guido van Rossum and first released in 1991. It is currently developed and maintained by the Python Software Foundation. The reference implementation, CPython, is open source and is what most engineers mean when they say "Python."
The Design Philosophy
Interactive animation: Typing import this in the interpreter prints the Zen of Python - readability counts, and errors should never pass silently.
Python's design philosophy is captured in a short document called The Zen of Python, accessible by typing import this in any Python interpreter. The principles that matter most in day-to-day work:
- Readability counts. Code is read far more often than it is written.
- There should be one - and preferably only one - obvious way to do it.
- Explicit is better than implicit.
- Simple is better than complex.
- Errors should never pass silently.
These are not just slogans. They show up in the language itself. Python enforces indentation as part of syntax. It avoids syntactic noise like braces and semicolons. Its standard library prefers clear function names over abbreviated ones. The community values code that a new reader can understand without commentary.
Interactive animation: The same discount check with braces and semicolons and in Python, where the indentation itself is the block structure.
What Python Is Used For
Python is one of the most widely used programming languages in production. Common application areas include:
Backend web development. Frameworks like Django, Flask, and FastAPI power production websites and APIs at scale. Python handles HTTP routing, request processing, database access, and business logic.
Data engineering and analysis. Libraries like Pandas, NumPy, and Polars are the standard tools for transforming and analyzing tabular data. Most data pipelines at modern companies have Python components.
Machine learning and AI. Python is the dominant language for ML work. PyTorch, TensorFlow, scikit-learn, and the Hugging Face ecosystem are Python-first. Research code and production inference both run on Python.
Scientific computing. Researchers in physics, biology, economics, and other fields use Python for simulation, modeling, and statistical analysis. The combination of NumPy, SciPy, and Jupyter notebooks is standard scientific tooling.
DevOps and automation. System administrators and infrastructure engineers use Python for scripting, configuration management, and tooling. Ansible, SaltStack, and many cloud SDKs are Python-based.
Education. Python is widely taught as a first programming language. Its readability makes it accessible to beginners while remaining powerful enough for production work.
The breadth matters. An engineer who knows Python well has access to roles across web development, data work, ML, infrastructure, and beyond. Few other languages span this many domains.
What Python Is Not Optimized For
Python has trade-offs. Knowing them helps choose when Python is and isn't the right tool.
Raw execution speed. Python is interpreted and dynamically typed, which makes it slower than compiled languages like C, C++, Rust, or Go for CPU-bound work. Workloads that need to be fast are typically written in those languages and called from Python, or use Python libraries that wrap C/C++ implementations (NumPy, for example).
Mobile applications. Python is not the standard language for iOS or Android development. Swift, Kotlin, and Java dominate those platforms.
Systems programming. Operating system kernels, device drivers, and low-level networking code are not written in Python. C, C++, and Rust own this space.
Hard real-time systems. Python's garbage collector and dynamic dispatch make latency unpredictable in ways that aren't acceptable for hard real-time work (avionics, medical devices, certain financial trading systems).
For most other workloads, Python is a reasonable choice, and frequently the best choice.
Interactive animation: When to reach for Python and when not - CPU-bound hot paths, mobile apps, kernels and hard real-time work.
Versions and Compatibility
Python has two major version lines that matter for working engineers:
Python 2.x was the dominant version through the mid-2010s. It reached end-of-life on January 1, 2020. New code should not target Python 2.
Python 3.x is the current major version. Within the 3.x line, releases come yearly. As of this writing:
- Python 3.13 is widely deployed and the safe default for new projects
- Python 3.12 is still common in production
- Python 3.11 and earlier are increasingly being phased out
- Python 3.14 is the most recent release
This course targets Python 3.13 as its baseline. Examples and patterns work on 3.13. Where a feature requires a newer version, it is noted explicitly.
Most code written for Python 3.10+ runs on later versions without changes. The language adds features over time but rarely removes them.
How Python Code Runs
Interactive animation: Pressing run, step by step - the source compiles to bytecode, cached in __pycache__, and the PVM executes it.
A short overview of what happens when Python code executes. This becomes important later when discussing performance, concurrency, and internals.
When a .py file runs:
- The Python interpreter reads the source code.
- It compiles the source to bytecode (a lower-level representation).
- The bytecode runs on the Python Virtual Machine (PVM).
- The PVM interprets bytecode one instruction at a time.
Bytecode is cached in .pyc files (usually inside a __pycache__ directory) to skip the compilation step on subsequent runs. This is automatic and rarely needs attention.
The reference implementation, CPython, is written in C. Other implementations exist:
- PyPy - a Python interpreter with a just-in-time (JIT) compiler. Significantly faster for some workloads.
- Jython - Python on the Java Virtual Machine. Rarely used today.
- IronPython - Python on .NET. Niche.
- MicroPython - Python for microcontrollers.
For nearly all professional work, "Python" means CPython. Other implementations are special-purpose tools.
What Comes Next
Interactive animation: The thirty modules in five stretches, from syntax fundamentals and data structures to real programs and professional work.
The rest of this course covers Python's language features and standard library in detail. The progression:
- Modules 2 through 4 cover syntax fundamentals: variables, types, operators, strings, and control flow.
- Modules 5 through 8 cover the core data structures: lists, tuples, sets, and dictionaries.
- Modules 9 through 11 cover functions and code organization.
- Modules 12 through 16 cover object-oriented programming.
- Modules 17 through 21 cover error handling, file I/O, iterators, functional patterns, and type hints.
- Module 22 covers concurrency.
- Modules 23 through 27 cover testing, debugging, databases, web frameworks, and data science.
- Modules 28 and 29 cover internals and best practices.
- Module 30 synthesizes the course for technical interviews.
The course assumes general programming experience (variables, conditionals, loops) but not Python experience specifically. Engineers coming from other languages can skim the early modules; new programmers should work through them carefully.
Interview Relevance
Interview: Interviewers rarely ask "what is Python?" directly, but they do probe whether candidates understand language trade-offs. Expect questions like "why did you choose Python for this?" or "what would change if you implemented this in Go?" Senior interviews push further: "how does CPython execute your code, and where does that affect performance?"
Module 30 covers Python interview preparation in detail.
Common Pitfalls
Warning: Treating Python as a slower Java. Python has its own idioms; translating Java patterns directly produces unidiomatic code.
Assuming Python is single-paradigm. It supports OOP, functional, and procedural styles. Most production codebases mix all three.
Targeting Python 2. End-of-life since 2020. Any new code targets Python 3.x.
Ignoring the standard library. Python's standard library is large and well-designed. Reaching for a third-party package before checking the standard library is a common waste of effort.
Conflating CPython with Python the language. Most performance characteristics described as "Python's" are actually CPython's. Other implementations behave differently.
Try It
Exercise: Get oriented before continuing:
- Open a Python interpreter and run
import this. Read the output.- Check your Python version: run
python3 --versionin a terminal. Note which version you have.- Find one production Python project on GitHub (Django, FastAPI, pandas, or scikit-learn). Browse the source for 10 minutes to see what professional Python code looks like.
- List three problems you would solve with Python and three you would solve with a different language. Justify each choice.