Python Hello World: Write and Run Your First Program
The Python Hello World program is one line: print("Hello, World!"). Run it and Python prints Hello, World! on the screen. That is the whole program, and every Python programmer, including the ones interviewing you at placements, started with exactly this line.
print("Hello, World!")
# Hello, World!
The rest of this page explains what the line is doing, shows three ways to run it, walks through the four errors almost everyone hits in their first ten minutes, and gives you three small next steps.
What print does
print is a built-in function. A function is a named piece of code that does a job when you call it, and you call it by writing its name followed by round brackets. Whatever you put inside the brackets is what print writes to the screen, followed by a new line.
"Hello, World!" is a string: a piece of text. The quotes tell Python where the text starts and ends. The quotes themselves are not printed. Single quotes work exactly the same way, and you can pass more than one thing to print, separated by commas; it puts a space between them.
print('Hello, World!')
print("Hello,", "World!")
print("Hello, World!", 2026)
# Hello, World!
# Hello, World!
# Hello, World! 2026
Notice there is no semicolon, no main function and no class. Python runs the file from the top, one line at a time. That is why the first program is one line and not ten.
Three ways to run it
1. In your browser, no install
The fastest way is the Python terminal on PyRun. It runs real Python in your browser, so there is nothing to download. Type print("Hello, World!"), press Enter, and the output appears on the next line. If you would rather write a small program instead of one line at a time, the practice editor gives you an editor with a Run button. This works on a college lab machine where you cannot install anything, and on a phone.
2. Save a file and run it
Once Python is installed on your computer, open any text editor (Notepad, VS Code, anything that saves plain text), type the one line, and save the file as hello.py. The .py extension is how Python and your editor know it is a Python file. Then open a terminal in the same folder and run it:
python hello.py
# Hello, World!
On macOS and most Linux systems the command is python3 hello.py; see the errors section below.
3. In the REPL
Type python (or python3) on its own in a terminal and you get the REPL, an interactive prompt that shows >>>. It reads one line, evaluates it, prints the result and waits for the next line. It is the best place to try things quickly.
>>> print("Hello, World!")
Hello, World!
>>> "Hello, World!"
'Hello, World!'
>>> exit()
The second line shows a REPL quirk: in the REPL you do not even need print, because it echoes the value of any expression. Notice the echo keeps the quotes, while print does not. Inside a .py file only print shows anything.
The classic first errors
Every one of these is normal. Read the last line of the error message first; Python 3.12 tells you what went wrong and usually where.
Missing quote or bracket: SyntaxError
print("Hello, World!)
SyntaxError: unterminated string literal (detected at line 1)
The closing quote is missing, so Python reaches the end of the line still inside the string. Forget the closing bracket instead and you get a different message for the same kind of mistake:
print("Hello, World!"
SyntaxError: '(' was never closed
A close cousin is curly quotes. If you copy code from a Word document or a chat app, the straight " often becomes “ and ”, which Python reports as SyntaxError: invalid character '“' (U+201C). Retype the quotes.
Print with a capital P: NameError
Print("Hello, World!")
NameError: name 'Print' is not defined. Did you mean: 'print'?
Python is case-sensitive. print, Print and PRINT are three different names, and only the first one exists. The same error appears if you forget the quotes entirely, because print(Hello) asks Python for a variable called Hello that was never created.
python vs python3 on Mac and Linux
On macOS and many Linux distributions the command python either does not exist or points at an old Python 2. Use python3 hello.py. If you see SyntaxError: Missing parentheses in call to 'print', you are running Python 2 by mistake; switch to python3.
"python is not recognized" on Windows
'python' is not recognized as an internal or external command means Windows cannot find Python, usually because the "Add python.exe to PATH" box was not ticked during installation. Sometimes typing python opens the Microsoft Store instead. Both fixes, and the rest of a clean setup, are in How to install Python on Windows, Mac and Linux. Or skip the install for today and run the line in the browser terminal.
Three tiny next steps
You have printed a fixed message. The next three programs each change one thing.
Put the message in a variable
A variable is a name for a value. Assign with =, then use the name anywhere you would have typed the value.
message = "Hello, World!"
print(message)
print(message)
# Hello, World!
# Hello, World!
Ask the user for their name with input()
input() shows a prompt, waits for the user to type something and press Enter, and gives you what they typed as a string.
name = input("What is your name? ")
print("Hello,", name)
Type Asha when it asks and you get:
What is your name? Asha
Hello, Asha
Build the message with an f-string
An f-string is a string with an f in front of it. Anything inside curly braces is replaced with its value, which is cleaner than joining pieces with commas.
name = "Asha"
year = 2026
print(f"Hello, {name}! Welcome to Python in {year}.")
# Hello, Asha! Welcome to Python in 2026.
That is variables, input and output in three programs, which is the entire toolkit for the first week of any Python course.
Continue with the free lesson
The Hello World lesson on PyRun covers this ground with runnable examples and a graded exercise that checks your output, and it is one of the first five lessons, which are free. Python runs in the browser with no install, so the only thing between you and the next line of code is a browser tab.