Introduction to Python
Discover what Python is, where it came from, why it dominates modern programming, and how to write your very first line of code.
What is Python?
Python is a high-level, interpreted, general-purpose programming language known for its clear syntax, readability, and versatility. It lets you build everything from simple scripts to complex web applications and machine learning models.
Python emphasizes code readability and uses indentation (whitespace) to define code blocks rather than curly braces or keywords, making it one of the easiest languages to learn and read.
A Brief History
Python was created by Guido van Rossum and first released in 1991. The name was inspired by the British comedy group Monty Python, not the snake.
- 1991: Python 0.9.0 released with classes, functions, exception handling, and core data types.
- 2000: Python 2.0 introduced list comprehensions, garbage collection, and Unicode support.
- 2008: Python 3.0 launched with breaking changes to fix fundamental design flaws.
- 2020: Python 2 reached end-of-life — all new projects should use Python 3.
- Today: Python consistently ranks as the #1 most popular programming language.
Why Python?
Simple Syntax
Python reads almost like English. You can accomplish more with fewer lines of code compared to languages like Java or C++.
Versatile
Web development, data science, AI/ML, automation, scripting, DevOps, game development — Python does it all.
Huge Ecosystem
Over 400,000 packages on PyPI (Python Package Index) covering every domain imaginable.
Community & Support
One of the largest developer communities means answers to nearly every question already exist online.
Python 2 vs Python 3
| Feature | Python 2 | Python 3 |
|---|---|---|
| Status | End-of-life (Jan 2020) | Actively maintained |
print "hello" | print("hello") | |
| Division | 5/2 = 2 (integer) | 5/2 = 2.5 (float) |
| Strings | ASCII by default | Unicode by default |
| Range | range() returns a list | range() returns an iterator |
Where Python is Used
Web Development
Django, Flask, and FastAPI power millions of websites and APIs worldwide.
Data Science
Pandas, NumPy, and Matplotlib are the backbone of data analysis workflows.
AI & Machine Learning
TensorFlow, PyTorch, and Scikit-learn make Python the #1 language for AI.
Automation & Scripting
Automate repetitive tasks, web scraping, system administration, and DevOps pipelines.
Your First Python Program
The classic "Hello, World!" program in Python is just one line:
print("Hello, World!")
That's it. No boilerplate, no imports, no class definitions. Just one clear line of code.
The Python REPL
Python includes an interactive REPL (Read-Eval-Print Loop) that lets you execute code line by line — perfect for experimenting and learning:
$ python3 Python 3.12.0 (main, Oct 2 2024) >>> print("Hello from the REPL!") Hello from the REPL! >>> 2 + 3 5 >>> name = "Python" >>> print(f"Welcome to {name}!") Welcome to Python! >>> exit()
python3 (or python on Windows) to start the REPL. Try some arithmetic expressions and print statements to get comfortable.