Python Basics · Getting Started · lesson 1 of 12
Hello, World and print()
about 8 minutes · free · runs in your browser
Step 1 of 2
Your first line of Python
Every programming language starts here. print() takes whatever you put between the
brackets and writes it to the console — the black panel below your editor.
print("Hello, World!")
The quotation marks matter. Text in Python is called a string, and a string has to be
wrapped in quotes so Python can tell the difference between a piece of text and the name
of something. print(Hello) would send Python looking for something called Hello and
fail; print("Hello") prints the word.
Single quotes work exactly the same as double quotes. 'Hello' and "Hello" are the
same string. Pick one and stay consistent.
Your turn: make the program print exactly Hello, World!
You start from this, and edit it in the browser:
# Print the greeting below this line.
Step 2 of 2
Printing several things
print() accepts more than one value if you separate them with commas. It puts a single
space between each one and moves to a new line at the end.
print("Python", "is", "fun")
That prints Python is fun — three separate values, joined with spaces by print
itself.
Each call to print() starts a new line, so two calls give you two lines of output.
Your turn: print two lines. The first should read Line one and the second
Line two.
You start from this, and edit it in the browser:
# Print two lines here.