Basics

Module 2 · Basics · Lesson 1 of 9

Your very first program

You've printed text and you've seen an error. Now let's write a program that actually does something — one that remembers a piece of information and uses it. That's the leap from “hello world” to real code.

A program that remembers
greet.py
name = "Ada"
print("Hello,", name)
print("Welcome to Python!")
Memory
name"Ada"
Terminal
$ python greet.py
Hello, Ada
Welcome to Python!

The first line creates a variable: name = "Ada" tells Python to remember the text "Ada" under the label name. Think of it as a labelled box you can put a value into and open again later.

The next line uses it: print("Hello,", name) prints the word Hello, followed by whatever's in the box — so you get Hello, Ada. Change the value to your own name, run it again, and the program greets you. That tiny change is the whole point: the program works with data, not just fixed words.

Don't just take our word for it — this is real Python, running right here in your browser. Change "Ada" to your own name (or add another print line) and press Run:

Run it yourselfruns in your browser · Python
main.py

That's exactly what happens when you save it as greet.py and run python greet.py on your own machine. You've written your first real program. From here, every new idea — more variables, doing maths, making decisions — just adds to this same foundation.