Published , Last updated
If you're just starting your Python journey, the first thing you’ll do is write the legendary "Hello, World!" program. But running that single line of code is more than a ritual, it’s your first step into real-world Python development.
Here, you’ll:
Before running any Python code, ensure Python is installed on your system:
1. Install and Manage Multiple Python Versions on Windows Using pyenv-win
2. How to Use Python venv: Create and Manage Virtual Environments
OR
- Visit: https://www.python.org/downloads
- Install the latest stable version (Python 3.x)
- Make sure to check "Add Python to PATH" during installation on Windows
- Verify Installation:
python3 --version
Let’s write the simplest program that outputs text to the screen.
Code: hello.py
print("Hello, World!")
This single line uses Python’s built-in print()
function to display text.
hello.py
Navigate to the folder where the file is saved:
cd path/to/your/folder
Run:
python hello.py
or
python3 hello.py
Ctrl + F5
Shift + F10
You should see output:
Hello, World!
While a single file works for simple tasks, real-world Python projects have multiple files and folders. Let’s create a basic directory structure:
my_first_project/
│
├── main.py
├── utils.py
├── requirements.txt
├── README.md
└── /modules
└── helper.py
main.py
– The main file to run the programutils.py
– Utility functions used across your projectrequirements.txt
– List of dependencies (for later use with pip)README.md
– Project overview/documentation/modules
– Folder to store reusable modules like helper.py
Make your Python file runnable from any location:
At the top of hello.py
, add:
#!/usr/bin/env python3
chmod +x hello.py
hello_world.py
python -m venv venv
) to isolate dependencies (explained in a later post)print()
for debugging while starting out
Congratulations! You’ve just written and run your first Python program. This small beginning opens up endless possibilities from automation scripts to full-stack web applications.
Understanding how to structure your projects and run your code from different environments will make your Python journey smoother and more productive.