⬅ Previous TopicIntroduction to Python
Next Topic ⮕Python Comments










Python Hello World Program
Hello World Program
Welcome to your very first step in learning Python!
We’re going to write a small program that tells the computer to say: Hello, World!
This is a tradition in programming — it’s how almost everyone starts learning any programming language.
Your First Python Program
Type this line exactly as it is:
print("Hello, World!")
How to Run This Program (Using a File)
- First, you need Python installed on your computer. Download it from python.org and follow the installation instructions based on your Operating System.
- Open a text editor like Notepad (Windows), TextEdit (Mac), or any code editor like VS Code.
- Type:
print("Hello, World!")
- Save the file as
main.py
(make sure it ends with.py
). This is the extension used for Python files. - Open your terminal or command prompt.
- Go to the folder where you saved the file.
- Type:
python main.py
and press Enter.
How to Run This Program (Using Python Shell)
You can also run Python code directly in the interactive shell — no file needed!
- Open your terminal or command prompt.
- Type
python
orpython3
and press Enter. - You’ll see a prompt like this:
>>>
- Now type your code:
>>> print("Hello, World!")
Hello, World!
This is called the Python interactive shell or REPL (Read-Eval-Print Loop). It's great for testing small pieces of code quickly.
That’s It!
You just wrote and ran your first Python program!