Hello World in Python: Your First Program (2026)
Run print("Hello World") in Python 3.13, understand why the Python 2 print statement breaks in Python 3, add an f-string variant, and spot three errors beginners make.
Python’s Hello World is one line: print("Hello World"). No imports, no main function, no semicolons.
The One Line That Runs
Here is the complete program:
# Python program to print Hello World
print("Hello World")
Output:
Hello World
Break down what Python does with that single line.
printis a built-in function. No import needed."Hello World"is a string literal — a sequence of characters between matching quote marks.- The parentheses call the function and pass the string as an argument.
- Python writes the string to the console and adds a newline at the end automatically.
That newline is why the cursor drops to the next line after the output appears. Nothing else happens. Python does not require a class, a main method, or any file header.
Python 3.13 (released October 2024) is the current stable version. If you are installing Python for the first time, download it from python.org/downloads and choose the installer for your operating system.
Where to Run It: IDLE, VS Code, and Replit
Three options for beginners, in order of setup friction:
IDLE
IDLE ships bundled with Python. After the installation, open IDLE from your Start menu (Windows) or your Applications folder (Mac). The interactive shell opens immediately. Type print("Hello World") and press Enter; it runs without any file creation.
For a script file: File → New File → type the program → Run → Run Module (or F5). IDLE is the zero-configuration option.
VS Code
VS Code is free, popular in engineering placements prep, and works on Windows, Mac, and Linux. Install the Python extension from the extensions panel. Create a file named hello.py, type the one line, and press F5. A terminal panel opens at the bottom showing the output.
Replit
Replit is browser-based. No installation at all. Open the link, click Run, and the output appears. Useful in college labs where students cannot install software on shared systems.
All three environments produce identical output. The choice depends on what’s available, not on Python itself.
What print() Actually Does
The Python documentation for print() defines the full function signature:
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
In practice, most uses look nothing like that signature. You pass a string and move on. But the defaults explain two things beginners sometimes puzzle over:
sep=' '— when you pass multiple arguments, Python puts a space between each one automatically.end='\n'— Python appends a newline after the last argument. You can override this withend=''to keep the cursor on the same line.
Python 2 vs Python 3
In Python 2, print was a statement, not a function. This was valid Python 2:
# Python 2 syntax — not valid in Python 3
print "Hello World"
Python 3 (first stable release: December 2008) replaced the statement with a function call. Python 2 reached end-of-life in January 2020. Any system running Python 3 requires the parentheses. That covers every system installed since 2020.
For more on printing variables alongside text, printing variables in Python covers all four formatting methods available in Python 3.
Two Variants Worth Knowing
Single Quotes and Double Quotes
Both produce the same output:
print('Hello World') # single quotes
print("Hello World") # double quotes
Python treats them identically. The convention in tutorials is double quotes; the convention inside strings that contain apostrophes is single quotes for the outer delimiter. Neither choice affects the output.
The f-String Variant
An f-string, introduced in PEP 498 and available from Python 3.6 onward, lets you embed a variable’s value directly inside a string:
name = "World"
print(f"Hello {name}")
Output:
Hello World
The f prefix before the opening quote tells Python to treat anything inside curly braces as an expression and evaluate it. Here {name} is replaced by the string "World" at runtime.
This matters as soon as Hello World stops being static. If you ask a user for their name with input(), you can greet them: print(f"Hello {name}") outputs the actual name they typed, not the literal text {name}.
To understand what name = "World" is doing, variables in Python covers assignment, naming rules, and data types.
Three Errors in the First Ten Minutes
Beginners encounter these three errors reliably, usually within the first session:
Missing Parentheses
print "Hello World"
Error message:
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
Python 3 actually suggests the fix in the error message. Add the parentheses and the error disappears.
Missing Quotes
print(Hello World)
Error message:
SyntaxError: invalid syntax
Python tries to evaluate Hello as a variable name, then runs into the space before World and fails. The fix is to wrap the text in quotes: print("Hello World").
Mismatched Quotes
print("Hello World')
Error message:
SyntaxError: EOL while scanning string literal
The opening quote is a double quote; the closing quote is a single quote. Python reads from the opening double quote and never finds a matching closing double quote before the end of the line. Fix: match the quote characters on both sides.
Unexpected Indent
print("Hello World")
Error message:
IndentationError: unexpected indent
Python uses indentation to define code blocks. Top-level statements must start at column zero. An accidental leading space before print throws this error. Delete the leading whitespace.
The Python practice programs collection is the next stop from here: 20-plus beginner programs (swap two numbers, find even or odd, sum a list) that all use print() and add one new concept each time.
Once print("Hello World") runs locally, the natural next experiment is making Python print something a language model generated rather than a string you hardcoded. TinkerLLM provides a Python environment where your code calls a real LLM. The print() mechanics are identical to what you just used; the model generates the string instead of you hardcoding it. Full access is ₹299.
Primary sources
Frequently asked questions
Does Python need semicolons at the end of each line?
No. Python uses newlines to terminate statements. Semicolons are optional and rarely seen in idiomatic Python code.
Why does print "Hello World" throw an error in Python 3?
In Python 2, print was a statement that needed no parentheses. Python 3 replaced it with a function where parentheses are mandatory. The error message reads: SyntaxError: Missing parentheses in call to 'print'.
What Python version should I install in 2026?
Python 3.13.x is the current stable release. Download it from python.org/downloads and choose the installer for your operating system (Windows, macOS, or Linux).
What is an f-string and when did it arrive in Python?
An f-string is a string prefixed with f that evaluates expressions inside curly braces at runtime. It was introduced in PEP 498 and shipped with Python 3.6 (2016). Any Python 3.6 or later installation supports f-strings.
Does it matter whether I use single or double quotes in Python?
No functional difference. Python accepts both. Choose one style and stay consistent within a project.
A self-paced playground for building with LLMs.
TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.
Try TinkerLLM (₹299 launch)