LESSON 01 · BEGINNER PATH6 min

Hello, World!

Run your first Python statements and recognize how Python displays output.

Video coming to YouTube

Work through the full lesson and run its code while the video is being prepared for publication.

Understand the concept

A Python program runs its statements from top to bottom. The print function sends a value to the output area, so it is a quick way to check what your code does.

Text is a string and needs quotes. Numbers can be written without quotes. Lines beginning with a hash sign are comments for people reading the code.

  • print() displays a value
  • Strings use quotes
  • Comments begin with #

See it step by step

Read the code, predict the output, then compare it with the result.

01. Print two messages

PYTHON
print("Hello, Maya!")
print("Welcome to Python.")
EXPECTED OUTPUT
Hello, Maya!
Welcome to Python.

Python runs these statements from top to bottom. Quotes mark each piece of text.

02. Print a calculation

PYTHON
print(7 + 5)
# This comment is ignored.
print("Done")
EXPECTED OUTPUT
12
Done

Python evaluates 7 + 5 before print() displays the result. The comment produces no output.

Try it in Python

Edit the example and run it. Python starts in your browser the first time you click Run.

Python console

Ready to run
Need input()? Add one value per line
Ctrl / ⌘ + Enter to run
OUTPUT
Your output appears here.
Your turnChange the greeting to include your name. Then print the result of 7 + 5 on a new line.
Need a hint?

First change the text inside the greeting's quotes, keeping the print() call. Then add a new print(7 + 5) line; the number should appear as 12.

Complete the task and select Check task to verify your code.

    Quick quiz

    Three questions. You can change your answers and try again.

    01.What does print("Hi") display?

    02.Which character begins a Python comment?

    03.What does print(3 + 4) display?

    Typical mistakes

    Everyone meets these errors. See what causes them and how to fix them.

    Unquoted text

    COMMON MISTAKE
    print(Hello)
    FIX
    print("Hello")

    What happens: NameError: Python looks for a variable named Hello.
    Put literal text inside quotes so Python treats it as a string.

    Missing parentheses

    COMMON MISTAKE
    print "Hello"
    FIX
    print("Hello")

    What happens: SyntaxError in Python 3.
    print is a function, so its argument goes inside parentheses.