Hello World in Python: Your First Program Explained
Learn to write and run a Hello World program in Python 3.14 using print(). Covers single quotes, double quotes, triple quotes, f-strings, and common beginner errors.
print("Hello, World!") is the entire program. One line, no imports, no class declarations, no semicolons. That minimal surface area is exactly why Python is the default first language in most Indian engineering colleges today.
This article walks through what that single line actually does, why the parentheses matter (a Python 3 vs Python 2 distinction that still trips up students copying old StackOverflow answers), and where to go after you have the output on your screen.
The One-Line Program
Here is the complete, working Hello World program in Python 3:
print("Hello, World!")
Save that single line in a file named hello.py, open a terminal, and run:
python3 hello.py
Output:
Hello, World!
What Happens Under the Hood
printis a built-in function — it ships with every Python installation, no import required."Hello, World!"is a string literal. The quotes mark the boundaries; the text between them is the data.- The function writes the string to standard output (stdout), appends a newline character, and returns
None.
That last detail matters once you start chaining operations. For now, the takeaway: print() always adds a newline unless you override it with end="".
Python 3 vs Python 2 — Why Parentheses Matter
If you copy code from a pre-2020 tutorial, you might see this:
# Python 2 syntax — will NOT work in Python 3
print "Hello, World!"
Running that in Python 3.14 (the current stable release as of April 2026) throws a SyntaxError:
SyntaxError: Missing parentheses in call to 'print'
The reason: Python 2 treated print as a statement (like return or import). PEP 3105 converted it into a proper function in Python 3, which means parentheses are mandatory.
Why This Still Matters in 2026
Python 2 reached end-of-life on 1 January 2020. No security patches, no bug fixes. Yet legacy tutorials still rank on Google, and students still paste Python 2 snippets into Python 3 environments. If your code throws a SyntaxError on a print line, check for missing parentheses first.
String Quoting Variations
Python accepts three styles of quote delimiters for strings. All produce identical output with print().
| Style | Syntax | Use case |
|---|---|---|
| Single quotes | print('Hello, World!') | Default for short strings without apostrophes |
| Double quotes | print("Hello, World!") | Default when the string contains an apostrophe |
| Triple quotes | print('''Hello, World!''') | Multi-line strings or strings with both quote types |
Escaping Quotes
When your string itself contains a quote character, you have two options:
- Use the other quote type as the delimiter:
print("It's working") - Escape with a backslash:
print('It\'s working')
Both produce:
It's working
Pick one convention for your project and stick with it. Most Python style guides (including PEP 8) accept either single or double quotes as long as the choice is consistent.
Beyond Static Text — f-strings and Variables
A static "Hello, World!" is useful for exactly one thing: confirming your setup works. Real programs print dynamic data. Python’s f-strings (formatted string literals, available since Python 3.6) handle this cleanly:
name = "Priya"
print(f"Hello, {name}!")
Output:
Hello, Priya!
The f prefix before the opening quote tells Python to evaluate any expression inside curly braces. You can put arithmetic, function calls, or method calls inside those braces:
print(f"2 + 3 = {2 + 3}")
print(f"Name in uppercase: {'priya'.upper()}")
Output:
2 + 3 = 5
Name in uppercase: PRIYA
Other Formatting Approaches
f-strings are the modern standard, but you will encounter older code using these alternatives:
str.format()—print("Hello, {}".format(name))%formatting —print("Hello, %s" % name)
Both still work in Python 3.14, but f-strings are faster at runtime and easier to read. Use them for all new code.
Running Your First Program
Three ways to execute Python code, in order of simplicity:
The Interactive REPL
Open a terminal and type python3:
$ python3
Python 3.14.4 (main, Apr 7 2026, 09:00:00)
>>> print("Hello, World!")
Hello, World!
>>> exit()
Good for one-off experiments. Not for saving work.
A .py File
Create hello.py with any text editor (VS Code, Sublime, or even Notepad), write your print statement, save, and run with python3 hello.py from the same directory.
An IDE or Online Editor
VS Code with the Python extension, PyCharm Community, or browser-based tools like Google Colab all work. For placement coding rounds, most platforms (HackerRank, HackerEarth, CoCubes) provide their own browser editors with Python 3 pre-configured.
Common First-Timer Errors
| Error | Cause | Fix |
|---|---|---|
SyntaxError: Missing parentheses | Using Python 2 print syntax | Add parentheses: print("...") |
SyntaxError: EOL while scanning string literal | Mismatched or missing closing quote | Match opening and closing quotes |
NameError: name 'Print' is not defined | Capital P in Print | Python is case-sensitive — use lowercase print |
UnicodeEncodeError on Windows | Terminal encoding mismatch | Run chcp 65001 or switch to PowerShell |
What to Build Next
Once Hello World runs, you have a confirmed Python environment. The natural next steps:
- Python example programs for practice — a curated set of beginner exercises that build on print, variables, and input.
- Calculator program in Python — combines print with arithmetic operators and user input.
- Character type checking in Python — applies string methods and conditional logic to single characters.
Each of these uses the same print() function you just learned, combined with one new concept at a time.
The f-string Connection to LLM Prompting
The f-string syntax you saw in the variables section (f"Hello, {name}") is the same pattern used when building prompts for large language models. A typical LLM API call in Python looks like:
prompt = f"Summarise this text in {num_sentences} sentences: {document}"
If you want to experiment with that pattern hands-on, TinkerLLM is a self-paced playground where you write and run Python prompts against real LLM APIs starting at ₹299. The same print() and f-string mechanics from this article apply directly.
Primary sources
Frequently asked questions
Does Python need a main() function like C or Java?
No. Python executes top-level code line by line from the top of the file. A main() function is a convention for larger projects, not a requirement. Your one-line print statement runs without any wrapping function.
What is the difference between print in Python 2 and Python 3?
In Python 2, print was a statement — you wrote `print "Hello"` without parentheses. In Python 3, print() is a function, so parentheses are mandatory. Python 2 reached end-of-life in January 2020; all new code should use Python 3 syntax.
Can I print multiple items in one print() call?
Yes. Pass multiple arguments separated by commas: `print("Hello", "World")` outputs `Hello World` with a space between them by default. Change the separator with the `sep` parameter: `print("Hello", "World", sep="-")` outputs `Hello-World`.
Why does my terminal show garbled characters instead of Hello World?
This usually means your terminal's character encoding does not match the file encoding. On Windows, open PowerShell (which defaults to UTF-8) instead of the legacy Command Prompt, or run `chcp 65001` to switch to UTF-8 before running your script.
Do I need to install anything to run Hello World in Python?
You need the Python interpreter. Check if it is already installed by running `python3 --version` in your terminal. If not found, download the latest release from python.org/downloads and follow the installer — the whole setup takes under 5 minutes.
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)