A Python program is a recipe — a list of instructions the computer reads top to bottom. The simplest instruction is also the most useful one: show me something. How would you ask Python to display the word Hello on the screen?
Maybe just write Hello and run the program?
That alone won't work — Python reads Hello and asks "is Hello a value you stored somewhere? a function? what should I do with it?". Bare words mean nothing to it. You have to use a built-in instruction called print and put what you want shown inside parentheses, in quotes:
print("Hello")Why the quotes around Hello?
Quotes mark the boundary of text — programmers call it a string. Without them, Hello looks like a name Python should look up. With them, Python knows: "this is the literal characters H-e-l-l-o, treat them as data, not as a thing to interpret".
Single or double quotes — does it matter?
Either works. 'Hello' and "Hello" produce the same result. Pick one and stay consistent. Most code you'll read uses double quotes.
And print does the showing — that's the verb of the instruction?
That's the verb. The parentheses hold the cargo. print("Hello") is read aloud as "print, the string Hello". Python obliges and writes Hello to the output.
So one line, one verb, one piece of data — and the computer does what I asked.
That's the whole shape of every Python statement you'll write today. Verb, parentheses, cargo. The exercise is one line of code; the lesson is the shape.
print() — the first builtinprint is a function — a unit of behaviour Python ships with, ready to call. To call a function you write its name followed by (...) parentheses. Whatever sits inside the parentheses is the argument — the data the function operates on.
print("Hello")This line tells Python: run the print function, give it the string Hello. Python writes Hello followed by a newline to the output, and the program ends.
The "Hello" is a string. Python supports both quote styles:
print("Hello")
print('Hello')Both produce the same output. The only time the choice matters is when the string itself contains a quote — "can't" works, 'can't' is a syntax error because Python thinks the string ends at 't.
You can pass more than one value, separated by commas. Python prints them with spaces between:
print("Hello", "world")
# → Hello worldA backslash inside a string starts an escape sequence. The two you'll see most:
| Sequence | Meaning |
|---|---|
\n | newline |
\t | tab |
print("Line one\nLine two")
# → Line one
# → Line twoprint runsThe program runs each line of code top to bottom. After print("Hello") finishes, Python looks for the next line. If there isn't one, the program exits. Your output is whatever print left behind.
print "Hello"That's Python 2 syntax. In Python 3 it's a SyntaxError. print requires parentheses — it's a function call, not a magic keyword.
A Python program is a recipe — a list of instructions the computer reads top to bottom. The simplest instruction is also the most useful one: show me something. How would you ask Python to display the word Hello on the screen?
Maybe just write Hello and run the program?
That alone won't work — Python reads Hello and asks "is Hello a value you stored somewhere? a function? what should I do with it?". Bare words mean nothing to it. You have to use a built-in instruction called print and put what you want shown inside parentheses, in quotes:
print("Hello")Why the quotes around Hello?
Quotes mark the boundary of text — programmers call it a string. Without them, Hello looks like a name Python should look up. With them, Python knows: "this is the literal characters H-e-l-l-o, treat them as data, not as a thing to interpret".
Single or double quotes — does it matter?
Either works. 'Hello' and "Hello" produce the same result. Pick one and stay consistent. Most code you'll read uses double quotes.
And print does the showing — that's the verb of the instruction?
That's the verb. The parentheses hold the cargo. print("Hello") is read aloud as "print, the string Hello". Python obliges and writes Hello to the output.
So one line, one verb, one piece of data — and the computer does what I asked.
That's the whole shape of every Python statement you'll write today. Verb, parentheses, cargo. The exercise is one line of code; the lesson is the shape.
print() — the first builtinprint is a function — a unit of behaviour Python ships with, ready to call. To call a function you write its name followed by (...) parentheses. Whatever sits inside the parentheses is the argument — the data the function operates on.
print("Hello")This line tells Python: run the print function, give it the string Hello. Python writes Hello followed by a newline to the output, and the program ends.
The "Hello" is a string. Python supports both quote styles:
print("Hello")
print('Hello')Both produce the same output. The only time the choice matters is when the string itself contains a quote — "can't" works, 'can't' is a syntax error because Python thinks the string ends at 't.
You can pass more than one value, separated by commas. Python prints them with spaces between:
print("Hello", "world")
# → Hello worldA backslash inside a string starts an escape sequence. The two you'll see most:
| Sequence | Meaning |
|---|---|
\n | newline |
\t | tab |
print("Line one\nLine two")
# → Line one
# → Line twoprint runsThe program runs each line of code top to bottom. After print("Hello") finishes, Python looks for the next line. If there isn't one, the program exits. Your output is whatever print left behind.
print "Hello"That's Python 2 syntax. In Python 3 it's a SyntaxError. print requires parentheses — it's a function call, not a magic keyword.
Create a free account to get started. Paid plans unlock all tracks.