Chapter 01 ยท Getting Started
Your First Program
Every programmer's journey starts with making the computer say one thing. In the next five minutes you will write and run real Python โ no installing anything.
Programming is just giving a very literal assistant a list of instructions. The assistant does exactly what you write โ no more, no less. Our first instruction is the simplest one: "say this out loud." In Python, saying something out loud is called printing.
The easiest way to run Python: our playground
You don't need to install anything to start. Open our free code playground in a new tab, choose Python at the top, type your code, and press Run. That's your whole workshop for this course. (Later you can install Python properly, but there's no rush.)
Your first line
Type this into the playground and press Run:
print("Hello, world!")
Congratulations โ you just wrote a program. Let's break down that one line:
printis a built-in function โ a ready-made instruction that means "show this."- The round brackets
( )hold the thing you want to print. - The quotation marks
" "mean "this is text" โ in Python, text wrapped in quotes is called a string.
Printing more than once
Each print starts a new line, so a program runs top to bottom like a recipe:
print("My name is Godfrey.")
print("I am learning Python.")
print("This is fun!")
Comments โ notes to yourself
Anything after a # is a comment: Python ignores it completely. Comments
are notes for humans reading the code.
# This line is just a note - Python skips it
print("Only this line runs.")
In the playground, print three lines: your name, your town, and one thing you want to build one day. Change the words and run it again โ breaking things and fixing them is exactly how you learn.
Forgetting the quotes. print(Hello) makes Python look for something named Hello and
fail. print("Hello") prints the text. Quotes = "this is literally text."
Recap
print(...)shows things on the screen.- Text goes in quotes โ that's a string.
#starts a comment that Python ignores.- Programs run top to bottom, one line at a time.