What Is Python?
Python is a high-level, interpreted programming language created by Guido van Rossum and first released in 1991. The name isn't about the snake โ Guido was a fan of the British comedy group Monty Python, so the language was named after "Monty Python's Flying Circus."
Being interpreted means Python code runs line by line, which makes it incredibly easy to test and debug. You don't need to compile anything. You write code, you run it, you see results. Simple.
Readability Matters
Python was designed around the idea that code is read far more often than it is written. The syntax enforces clean structure โ indentation isn't optional, it's part of the language. This means Python code from different programmers tends to look similar, making collaboration much easier.
print("Welcome to Python")
print("Clean and simple")
Where Python Is Used
Python's versatility makes it one of the most widely used programming languages in the world. Here are some of its major applications:
- Web Development: Frameworks like Django and Flask power millions of websites, including Instagram, Spotify, and YouTube.
- Data Science and Analytics: Libraries like Pandas, NumPy, and Matplotlib make data manipulation and visualization straightforward.
- Machine Learning and AI: TensorFlow, PyTorch, and scikit-learn are all Python libraries used to build intelligent systems.
- Automation and Scripting: Python excels at automating repetitive tasks, from renaming files to scraping websites.
- Game Development: Libraries like Pygame let you create 2D games with Python.
- Scientific Computing: NASA, CERN, and research institutions worldwide use Python for simulations and data analysis.
Python 2 vs Python 3
You might encounter references to Python 2 and Python 3. Python 3 was released in 2008 and is the current version. Python 2 reached its end of life in January 2020, meaning it no longer receives security updates or bug fixes.
Always use Python 3 for new projects. If you're following an older tutorial that uses Python 2 syntax, be aware of a few differences:
# Python 3 (current)
print("Hello") # function call
input("Enter: ") # input function
# Python 2 (deprecated)
print "Hello" # statement
raw_input("Enter: ") # different function
When in doubt, use Python 3. All modern libraries and frameworks require it.
Setting Up Your Environment
A good development environment makes learning Python much smoother. Here's what you need:
- Python interpreter: Download from python.org. Always get the latest version.
- Code editor: VS Code is excellent for beginners. Install the Python extension for syntax highlighting, debugging, and IntelliSense.
- Terminal: Use the built-in terminal in VS Code or your system's command prompt to run Python scripts.
Once installed, open a terminal and run:
python --version
python -c "print('Python is working!')"
If you see the version number and the test message, your environment is ready.
Your First Python Script
Create a file called hello.py with the following content:
# A simple Python script
name = input("What is your name? ")
print(f"Hello, {name}! Welcome to Python.")
# Basic math
a = 10
b = 3
print(f"{a} + {b} = {a + b}")
print(f"{a} * {b} = {a * b}")
print(f"{a} / {b} = {a / b:.2f}")
Run it from your terminal:
python hello.py
This script demonstrates three fundamental concepts: variables (storing data), input() (getting user input), and print() (outputting results). Every Python program is built from these building blocks.