30 Mins

1. Introduction to Python

Introduction

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.

Python 3
print("Hello, World!")
OutputHello, World!

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.

Python 3
# This is a Python comment — Python ignores this line
print("Python is clean")
print("No semicolons needed")
OutputPython is clean No semicolons needed

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
Quick Check: Open your terminal and type python3 --version. If you see something like Python 3.11.x, you are ready to go.

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.
Python 3
# Save this as hello.py and run: python3 hello.py
print("Running from a script file!")
print("This is Python Script Mode.")
OutputRunning from a script file! This is Python Script Mode.

Knowledge Check

Ready to test your understanding of 1. Introduction to Python?

Back