Print "Hello, World!" in Python

One print. If this runs, Python is actually installed.

BeginnerBasic Python ProgramsExample 1 of 25
print-hello-world.py
1# if this prints, Python is installed
2print("Hello, World!")

Output

Hello, World!

In this one

  • print() is a full program
  • quotes = string, no quotes = name error

What's going on

print("Hello, World!") is the whole program. No class, no main, no ceremony.

print is built in. Quotes make a string. Drop the quotes and Python looks for a variable named Hello.

Single or double quotes both work. Mixing them in the same string is the thing that blows up.

Run it with python hello.py. The text shows up in the same place you typed the command.

After this program

If the idea is still fuzzy, read Day 1: Introduction to Python in the Python course. For a short check, try the Python quiz (300 questions). Stay with all 25 basic python programs, or see every topic on Python exercises.