Saying hello
The first thing every programmer learns is how to show something on the screen. In Python we use print():
print("Hello, World!")Output
Hello, World!
Let's break it down:
printis a function – a built-in command that does a job. Its job is to show things on the screen.- The round brackets
( )hold what you want to print. - The quotes
" "tell Python thatHello, World!is text.
Printing several lines
Every print() starts on a new line. Python runs your code from top to bottom, one line at a time:
print("Line one")
print("Line two")
print("Line three")Output
Line one Line two Line three
Printing numbers
Numbers don't need quotes. Python can even do maths before printing:
print(25)
print(10 + 5)
print(3 * 4)Output
25 15 12
Common mistake:
print("10 + 5")prints the text10 + 5, not15. Anything inside quotes is treated as plain text.
Printing several things at once
Separate values with commas. Python puts a space between them:
print("I am", 20, "years old")Output
I am 20 years old
Empty lines
An empty print() prints a blank line, which helps make output easier to read:
print("Top")
print()
print("Bottom")Output
Top Bottom
Remember: Python is case-sensitive.