Your First Python Program: Hello World
Introduction
When learning any programming language, the very first program you write is usually Hello World.
This simple program prints a message to the screen and confirms that your Python installation and environment are working correctly.
The Hello World Program
Here is the simplest Python program you can write:
print("Hello World")
How It Works
Let's break it down.
print()
print() is a built‑in Python function used to display output in the terminal or console.
print("Hello World")
When Python executes this line, it sends the text inside the parentheses to the screen.
"Hello World"
The text inside quotes is called a string. Strings represent text data in Python.
print("Hello World")print("Python is fun")print("Welcome to programming")
Each of these lines prints a different message.
Running the Program
To run this code:
- Open your Python editor.
- Create a file called:
hello.py - Add the code:
print("Hello World")
Run the file. You should see the following output:
Hello World
Why Every Language Starts With Hello World
The Hello World program is used because it is:
- Simple
- Easy to understand
- A quick way to verify that your programming environment works
Every major programming language has a version of this program.
Try It Yourself
Modify the message and print your own text.
print("Hello, my name is Alex")print("I am learning Python")
