1. Introduction to Python
Introduction to Python
Python is one of the most popular programming languages in the world — and for good reason. It was designed to be readable, simple, and powerful. Whether you want to build websites, analyze data, automate tasks, or create AI models, Python can do it all.
Python was created by Guido van Rossum and first released in 1991. Today it consistently ranks as the #1 most-used language in the world by both beginners and professionals.
What Can Python Do?
Python's versatility is its superpower. It is used across nearly every domain in technology:
- Web Development — Frameworks like Django and Flask power millions of websites
- Data Science & Analytics — Libraries like Pandas and NumPy make crunching millions of rows trivial
- Machine Learning & AI — TensorFlow and PyTorch are built on Python
- Automation & Scripting — Automate repetitive tasks, rename files, send emails programmatically
- Cybersecurity — Penetration testers and ethical hackers rely on Python tools daily
Your First Python Program
The tradition in programming is to start by making your program print Hello, World! to the screen. In many languages this takes multiple lines. In Python, it takes exactly one.
The print() function tells Python to display whatever is inside the parentheses to the screen. It is one of the most frequently used tools you will ever write.
Python Syntax vs Other Languages
One of the first things you will notice about Python is how clean it looks compared to other languages. There are no semicolons at the end of lines, and no curly braces to wrap blocks of code. Python uses indentation (whitespace) to define structure.
The # symbol marks a comment. Comments are notes for humans reading the code — Python completely ignores them at runtime.
Python Versions
There are two major versions of Python: Python 2 and Python 3. Python 2 is officially retired and no longer receives security updates. You should always use Python 3. This entire course is written for Python 3.
- Check your Python version by running python --version in your terminal
- Most modern systems ship with Python 3 pre-installed
- You can download the latest version from python.org
Running Python Code
There are two primary ways to run Python code. Understanding both is important as a developer:
- Interactive Mode — Open a terminal, type python3, and press Enter. You can now type Python code line by line and see instant results. Great for experimenting.
- Script Mode — Write your code in a .py file (e.g., hello.py), then run it from the terminal with python3 hello.py. This is how real programs are built.
Knowledge Check
Ready to test your understanding of 1. Introduction to Python?