Hello, World!

Programming Languages · Python Basics · 8 min

Make Python talk: print text and numbers, and leave notes for humans.

Your first line of code

A program is a list of instructions for the computer. The simplest instruction in Python is print(): whatever you put inside the brackets appears on the screen.

Text goes inside quotes, so Python knows it's text and not code:

print("Hi there")
  • Print Hello, World!

One print, one line

Each print() starts a new line. Python runs your lines from top to bottom, in order, like reading a recipe.

print("Step 1")
print("Step 2")
  • Print I am learning Python on the first line.

  • On the next line, print It is fun.

Numbers don't need quotes

Numbers are different from text. Leave out the quotes and Python treats them as numbers, so it can do maths with them:

print(7)
print(2 + 3)

The second line prints 5, not 2 + 3. With quotes, print("2 + 3") would print the text exactly as written.

  • Print the result of 12 * 4 (no quotes).

Comments are notes for humans

A line that starts with # is a comment. Python skips it completely. Programmers use comments to explain why the code does something.

# This line is ignored
print("This one runs")
  • Add a comment that says what the program does.

  • Below it, print Comments are skipped.

Put it together: a name badge

Time to combine everything. Make a little name badge that prints three lines. You can use your own name.

  • Print HELLO on the first line.

  • Print my name is on the second line.

  • Print any name on the third line.

More in Python Basics

Next: Variables