Python Tutorial
Introduction to Python
Python is a high-level, general-purpose programming language known for its clean, readable syntax. Created by Guido van Rossum and first released in 1991, it has grown into one of the most popular languages in the world — the language of choice for data science, machine learning and AI, web back ends, automation, scripting, and teaching programming.
This lesson explains what Python is, its key features, its advantages and limitations, a short history of its versions, and the kinds of applications people build with it, so you know what you are learning and why it is worth your time.
What Is Python?
Python is an interpreted, dynamically typed, garbage-collected language that supports several programming styles: procedural, object-oriented and functional. You write source code in .py files; the Python interpreter compiles it to bytecode and executes it line by line, so there is no separate compile step. The reference implementation, CPython, is written in C; others include PyPy (a fast JIT-compiled Python) and MicroPython (for microcontrollers).
Key Features
The features that make Python stand out:
- Readable syntax — indentation defines code blocks, so programs look clean and consistent.
- Interpreted and interactive — run code instantly in the REPL without compiling.
- Dynamically typed — variables do not need type declarations; optional type hints add safety.
- Batteries included — a large standard library for files, JSON, dates, networking, testing, and more.
- Huge ecosystem — over 500,000 packages on PyPI: NumPy, pandas, FastAPI, Django, PyTorch, scikit-learn...
- Cross-platform — the same code runs on Windows, macOS and Linux.
- Multi-paradigm — procedural, object-oriented and functional styles all work naturally.
- Free and open source — maintained by the Python Software Foundation and a large community.
Advantages and Limitations
Python lets you write working programs with far fewer lines than Java or C++, which makes it fast to learn and fast to develop with. Its libraries cover almost every domain. The trade-offs: pure Python code runs slower than compiled languages (performance-critical parts are usually written in C and wrapped, which is exactly what NumPy does); dynamic typing can hide bugs until runtime; and it is rarely used for mobile apps or browser front ends. For most business, data and automation work, developer speed matters more than raw execution speed.
A Short History
Guido van Rossum began Python in the late 1980s and named it after the comedy group Monty Python. Python 2.0 (2000) added list comprehensions and garbage collection; Python 3.0 (2008) cleaned up the language in backward-incompatible ways (for example print became a function). Python 2 reached end of life in 2020. Since then Python releases a new 3.x version every October: 3.10 added match statements, 3.11 and 3.12 brought large speed-ups and better error messages, 3.13 added an experimental free-threaded build and a new REPL, and 3.14 continued those improvements. Always learn and use Python 3.
What Is Python Used For?
Common application areas:
- Web development and APIs — FastAPI, Django, Flask.
- Data science and analytics — NumPy, pandas, Matplotlib, Jupyter.
- Machine learning and AI — scikit-learn, PyTorch, TensorFlow, LLM applications.
- Automation and scripting — renaming files, scraping websites, sending reports, DevOps tooling.
- Data apps and dashboards — Streamlit.
- Desktop GUIs and games — Tkinter, PyQt, Pygame.
- Testing, security and scientific computing — pytest, penetration-testing tools, simulations.
Examples
Python in a few lines: a word counter
text = "python is easy and python is powerful"
counts = {}
for word in text.split():
counts[word] = counts.get(word, 0) + 1
for word, count in sorted(counts.items()):
print(word, count)
and 1
easy 1
is 2
powerful 1
python 2
Checking which Python version is running
import sys
import platform
print("Python version:", platform.python_version())
print("Major version:", sys.version_info.major)
print("Is Python 3?", sys.version_info.major == 3)
Python version: 3.12.9
Major version: 3
Is Python 3? True
Common Mistakes
- Following Python 2 tutorials (print "hello" without parentheses, raw_input) — they do not work in Python 3.
- Assuming Python is only for beginners or scripts; it powers large production systems at many major companies.
- Expecting pure Python loops to be as fast as C; use libraries like NumPy for heavy numeric work.
- Confusing Python the language with Anaconda or Jupyter, which are distributions and tools built around it.
Key Points to Remember
- Python is an interpreted, dynamically typed, multi-paradigm language focused on readability.
- It has a large standard library and one of the biggest package ecosystems (PyPI).
- Python 3 is the only current version; new 3.x releases arrive every October.
- It is used for web back ends, data science, AI, automation, dashboards, GUIs and more.
- Its main trade-off is slower raw execution, offset by fast development and C-backed libraries.
Practice the examples
Change an input, predict the result, then compare it with the output. Explain why the result changes.