← Python from Scratch
Lesson 2 of 78 · 10 XP
How Python reads a program
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
A Python program is an ordinary text file. Python reads it from top to bottom, line by line, and runs each command right away.
The first command everyone learns is print(). It displays whatever is inside the parentheses:
print("Hello!")
print("This is the second line")
Text goes in quotes — double "..." or single '...'. Numbers are written without quotes:
print(2 + 3) # prints 5
print("2 + 3") # prints 2 + 3 — it's just text
Three syntax rules worth remembering from day one:
- Case matters.
printandPrintare different words; Python doesn't know the second one. - Brackets and quotes always come in pairs.
print("Hello)is an error: the quote isn't closed. - Indentation has meaning. For now, start every line at the very left edge. Later, indentation will mark blocks of code.
Task. Print two lines, exactly like this:
Hello, IGD!
I'm learning Python
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.