New to Python? Start here.
Your first program is a tradition: “Hello, World!”. This lesson shows you how to write and run it.
Python Fundamentals for Beginners Free Course
Master Python basics, from variables to data structures and control flow. Solve real-time problems and build practical skills using Jupyter Notebook.
Why “Hello, World!”?
It is a simple program. It shows you know the basic syntax. It is a tradition for starting any programming language.
The Code
Open a text editor. Type this:
print("Hello, World!")
Save the file. Name it hello.py.
What This Code Does
print()
is a function. A function is a block of code. It runs when you call it. The print()
function shows messages on the screen.
“Hello, World!” is a string. A string is text. The text must be in quotes.
Run Your Code
Go to your terminal or command prompt. Navigate to the folder where you saved hello.py.
Type this command and press Enter:
python hello.py
The Output
You will see this on your screen:
Hello, World!
You just wrote your first Python program.
Common Questions
- Do I need the quotes (“”)? Yes. The text inside
print()
must be a string, so it needs quotes. - What are the parentheses () for? They are part of the function’s syntax. The information inside is called an argument.
- Why print? It’s a built-in Python function that outputs text to the console.
This lesson is a part of the Python Tutorial.
Next: How Python Code Runs
Previous: Choosing a Python IDE or Editor