Skip to content
Happy Programming Guide
Start learning
Python

Introduction to Python

What Python is, what people build with it, how it compares with other languages, and how to run your first program in under five minutes.

Shelves of books in a library

Python is a general-purpose programming language designed to be readable. It is used for data analysis, web servers, automation scripts, machine learning and scientific work, and it is the language most often recommended to people who have never programmed before — because you can write something useful on your first day.

Why it reads the way it does#

Compare the same idea in two languages:

JAVA
// Java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello");
    }
}
Python
# Python
print("Hello")

Python removes ceremony that other languages require: no class wrapper for a script, no type declarations, no semicolons, no braces. Indentation defines structure, which forces the code to be laid out the way it reads.

That design has a cost. Python is slower than compiled languages, and mistakes that a compiler would catch in Java or C# surface only when the line actually runs. For most work the trade is worth it; for a real-time game engine it is not.

What people build with it#

Area Typical tools
Data analysis pandas, NumPy, Jupyter
Machine learning scikit-learn, PyTorch, TensorFlow
Web back ends Django, Flask, FastAPI
Automation and scripting the standard library, requests
Testing and tooling pytest, Selenium, Playwright
Scientific computing SciPy, astropy, biopython

Where it is a poor fit: mobile apps, browser front ends (that is JavaScript), and anything where every millisecond counts.

Installing it#

Download the latest Python 3 from python.org. On Windows, tick Add python.exe to PATH during installation — skipping that box is the single most common setup problem.

Terminal
python --version
python3 --version      # macOS and Linux often need the 3

macOS ships with an old Python for system use. Install your own rather than relying on it.

Your first program#

Save this as hello.py and run python hello.py from the same folder:

Python
name = input("What is your name? ")
print(f"Hello, {name}!")

years = int(input("How old are you? "))
print(f"In ten years you will be {years + 10}.")

Four lines, and it already reads input, converts a type and formats output. That immediacy is a large part of why Python is recommended first.

What the language looks like#

Python
# Variables - no type declarations
name = "Ana"
age = 34
price = 12.99
is_member = True

# Conditions - indentation defines the block
if age >= 18:
    print("adult")
elif age >= 13:
    print("teenager")
else:
    print("child")

# Loops
for fruit in ["apple", "pear", "plum"]:
    print(fruit)

for i in range(5):
    print(i)

# Functions
def average(numbers):
    if not numbers:
        return 0
    return sum(numbers) / len(numbers)

# Lists and dictionaries
scores = [88, 72, 95]
person = {"name": "Ana", "age": 34}

# Building a new list from an old one
passing = [s for s in scores if s >= 70]

The batteries-included library#

A great deal comes with Python and needs no installation:

Python
from pathlib import Path
import json, csv, sqlite3, datetime, random, re

Path("data").mkdir(exist_ok=True)
print(json.dumps({"ok": True}))
print(datetime.date.today())
print(random.choice(["a", "b", "c"]))

Learning what is already in the standard library saves more time than any single other habit — a surprising number of small libraries exist to do something Python already does.

Installing packages#

Terminal
python -m venv .venv

source .venv/bin/activate        # macOS and Linux
.venv\Scripts\activate           # Windows

python -m pip install requests
python -m pip freeze > requirements.txt

Make a virtual environment per project from the very beginning. It keeps each project’s packages separate, and it prevents the single most common category of beginner error — imports failing because the package went somewhere else.

How it compares#

Python JavaScript Java / C#
Typing dynamic dynamic static
Runs in a browser no yes no
Speed moderate fast fast
Learning curve gentle moderate steeper
Strongest in data, scripting, ML web front ends large applications

Learning one makes the next much easier. Loops, functions and conditions are the same ideas everywhere; only the punctuation changes.

What to learn, in order#

  1. Variables and types — strings, numbers, booleans
  2. Conditions — if, elif, else
  3. Loops — for and while
  4. Lists and dictionaries
  5. Functions — and returning values rather than printing
  6. Files — reading and writing
  7. Errors — try and except
  8. Modules and virtual environments

Then pick a direction — pandas for data, Flask or Django for web, or automation for anything tedious you do by hand.

Questions people ask#

Python 2 or Python 3?

Python 3, without qualification. Python 2 reached end of life in 2020 and receives no fixes. A tutorial writing print "hello" without brackets is for Python 2 and should be replaced.

Do I need an IDE?

Not to start — a text editor and a terminal are enough. VS Code with the Python extension is the common free choice and gives you error highlighting as you type, which shortens the feedback loop considerably.

Is Python fast enough?

For most work, yes. Where it is not, the heavy lifting usually happens in NumPy or a similar library whose core is written in C, so the Python layer is only orchestrating.

How long until I can build something real?

A useful script in days. Something with a database and users in a few months of regular practice. The gap between reading about code and writing it is closed only by writing it.

Where to go next#

Python basics, with the syntax you will use dailyRead next

Keep reading

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *