Your First Programs
beginner10 min readLesson 3 of 169
print, comments, and the shape of a program.
The smallest useful instruction in Python prints text on the screen:
print("Hello, world!")
print is a function: a named action you can invoke. The parentheses hold the
arguments โ here, the text to show. Text inside quotes is a string;
numbers work too, and print can show several things at once:
print(42)
print("Age:", 42)
Comments โ notes to humans
Anything after # on a line is ignored by the interpreter. Comments explain why:
# convert minutes to seconds
seconds = minutes * 60
Programs run top to bottom
print("first")
print("second")
print("third")
Always prints in that order. That simple fact is your first mental model of program flow: execution is a sequence.
Try it now
In the practice set that follows this lesson you will print formatted output, do small calculations, and predict what broken programs print. Reading is fine; now you type.