Skip to content
Happy Programming Guide
Start learning
Python

Python for Beginners: A Complete Starting Guide

Everything you need to begin with Python: what it is good at, how to install it, your first program, the core syntax, and a realistic order to learn things in.

Python is a general-purpose programming language known for reading almost like English. It is the most common first language for good reason: you spend your energy on ideas rather than punctuation.

This guide covers what Python is for, how to get it running, and the order to learn things in.

What Python is good at#

  • Automation — renaming a thousand files, filling spreadsheets, scraping a page, sending reports
  • Data work — cleaning, analysing and charting information
  • Back-end web development — with Django or Flask
  • Scripting and glue — small tools that connect other tools
  • Learning to program — the syntax stays out of your way

It is a weaker choice for iPhone and Android apps, and for anything running inside a web browser, where JavaScript is the natural fit.

Getting Python running#

Two options, and both are fine:

  • Online editor — no installation, works on any machine, good for the first week.
  • Installed locally — needed the moment you want to work with your own files. Follow how to install Python.

Check an installation from a terminal:

Terminal
python --version

If that prints something like Python 3.12.4, you are ready. If it errors, the install guide covers the usual causes.

Your first program#

Create a file called hello.py with one line:

Python
print("Hello, world!")

Then run it:

Terminal
python hello.py

Walked through in detail in your first Python program.

The syntax you will use every day#

Variables#

Python
name = "Ada"
age = 36
height = 1.7
is_student = False

No type declarations, no semicolons. See Python variables explained.

Getting input and showing output#

Python
name = input("What is your name? ")
print(f"Nice to meet you, {name}.")

That f before the quotes makes an f-string, which lets you drop variables straight into text. It is the most convenient thing in the language.

Decisions#

Python
marks = 82

if marks >= 80:
    print("Distinction")
elif marks >= 50:
    print("Pass")
else:
    print("Try again")

Indentation is not decoration in Python — it is how the language knows what is inside the if. See Python if/else statements.

Repetition#

Python
for item in ["pen", "book", "bag"]:
    print(item)

count = 3
while count > 0:
    print(count)
    count -= 1

Collections#

Python
scores = [10, 8, 9]                       # list
student = {"name": "Ada", "score": 90}    # dictionary

print(scores[0])          # 10
print(student["name"])    # Ada

Detail in Python lists and Python dictionaries.

Functions#

Python
def bmi(weight_kg, height_m):
    return round(weight_kg / (height_m ** 2), 1)

print(bmi(70, 1.75))   # 22.9

Reading and writing files#

This is where Python starts feeling genuinely useful.

Python
with open("notes.txt", "w") as f:
    f.write("First line
")

with open("notes.txt") as f:
    print(f.read())

The with block closes the file for you, even if something goes wrong.

Using other people’s code#

Python ships with a large standard library, and there is a package for almost everything else.

Python
import random
print(random.randint(1, 6))     # a dice roll
Terminal
pip install requests

A learning order that works#

  1. Print, variables, input, data types
  2. Conditions, then loops
  3. Lists and dictionaries
  4. Functions
  5. Reading and writing files
  6. Errors and try / except
  7. Importing modules and installing packages
  8. A real project — do not skip this

Most people stall around step 4 because they keep watching tutorials instead of building. Break the pattern at step 3 by making something small.

Questions people ask#

Python 2 or Python 3?

Python 3. Python 2 reached end of life in 2020. If a tutorial uses print "hello" without brackets, it is out of date — find a newer one.

How long until I can build something useful?

With consistent practice, a few weeks is enough for genuinely useful small scripts — a file organiser, a data cleaner, a reminder tool. Those small wins are what keep people going.

Do I need an IDE?

VS Code with the Python extension is free and does everything you need. See VS Code setup for beginners.

What is a virtual environment?

A separate folder of packages for one project, so two projects can use different versions without clashing. Not urgent on day one, worth learning by the time you have two projects.

Where to go next#

Next lessonHow to install Python (and check it worked)

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 *