If you’re thinking about learning programming, Python is one of the best places to start. It’s known for being beginner-friendly, versatile, and widely used in fields like web development, data science, artificial intelligence, and automation.
When I first started programming, Python was my go-to language because its clean and readable syntax made it easy to focus on problem-solving rather than just memorizing complicated rules.
In this post, I’ll walk you through a step-by-step path from installing Python all the way to building your first mini project. If you follow along, you’ll have a working script, some tests, and even a GitHub portfolio project by the end.
Step 1: Install Python
The first step is simple: install Python on your computer.
- Go to python.org.
- Download the latest stable 3.x version (don’t use Python 2—it’s outdated).
- Run the installer and make sure you check the box that says “Add Python to PATH.”
Once installed, open your terminal (Command Prompt, PowerShell, or terminal app) and verify:
python --version
You should see something like:
Python 3.11.5
Congratulations—you now have Python running on your system.
Step 2: Create a Virtual Environment
Before you dive into coding, it’s good practice to work inside a virtual environment. This isolates your project so that packages and dependencies don’t conflict with other projects.
Run the following commands:
# Create a virtual environment
python -m venv venv
Then activate it:
- macOS/Linux:
source venv/bin/activate - Windows:
venv\Scripts\activate
When activated, you’ll see (venv) before your command line prompt. This means you’re now working inside your isolated project environment.
Why does this matter? Because as your projects grow, different ones might require different package versions. Virtual environments keep things neat and professional.
Step 3: Write Your First Script (“Hello World”)
The best way to learn is by writing code. Let’s create a simple file called hello.py:
def greet(name):
return f"Hello, {name}!"
if __name__ == "__main__":
print(greet("Maksud"))
Now run it:
python hello.py
Output:
Hello, Maksud!
That’s it — your very first Python program!
What you’ve just done:
- Defined a function (
greet) that takes input and returns output. - Used f-strings (Python’s way of formatting strings).
- Wrote a main block (
if __name__ == "__main__":) which ensures the code only runs when the file is executed directly.
This structure will appear in almost every Python program you write.
Step 4: Install a Package
Python is powerful because of its ecosystem of packages. These are reusable modules created by other developers that you can install and use instantly.
For example, let’s use the popular requests package to make an HTTP request:
pip install requests
Then create a new file, http_example.py:
import requests
def fetch_url(url):
response = requests.get(url)
return response.status_code, response.text[:200]
if __name__ == "__main__":
status, content = fetch_url("https://www.python.org")
print(f"Status: {status}")
print("Preview:", content)
Run it:
python http_example.py
You’ll see the status code (200 = OK) and a short preview of the page content.
This small script introduces you to real-world applications: pulling data from the web.
Step 5: Build a Tiny Project
Now that you know the basics, it’s time to create something slightly more useful: a command-line tool that reads a CSV file and prints summary stats.
Let’s call it analyze_csv.py:
import csv
import sys
def analyze_csv(filename):
with open(filename, newline="") as f:
reader = csv.reader(f)
header = next(reader)
rows = list(reader)
print(f"Columns: {header}")
print(f"Total rows: {len(rows)}")
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python analyze_csv.py <filename>")
else:
analyze_csv(sys.argv[1])
Save a simple CSV file called data.csv:
Name,Age,City
Alice,30,New York
Bob,25,Chicago
Charlie,35,Los Angeles
Run:
python analyze_csv.py data.csv
Output:
Columns: ['Name', 'Age', 'City']
Total rows: 3
You now have your first data analysis script! Small, but useful.
Step 6: Add Tests
Professional software is always tested. Let’s add a simple test using pytest.
First, install pytest:
pip install pytest
Create a file test_greet.py:
from hello import greet
def test_greet():
assert greet("Maksud") == "Hello, Maksud!"
assert greet("Python") == "Hello, Python!"
Now run the test:
pytest
Output:
collected 1 item
test_greet.py . [100%]
All tests passed! 🎉
This step introduces you to Test-Driven Development (TDD) — the practice of writing tests to ensure your code works as expected.
Step 7: Put It in Git & GitHub
The final step is to make your project shareable. Using Git allows you to track your progress, and GitHub makes your work public (and portfolio-ready).
Initialize your repo:
git init
git add .
git commit -m "Initial commit: Python beginner project"
If you already have a GitHub account:
- Create a new repository.
- Follow the instructions GitHub provides to push your code.
Now anyone can see your project online — and you can proudly share it in your portfolio.
Next Steps
At this point, you’ve:
✅ Installed Python
✅ Created a virtual environment
✅ Written a “Hello World” program
✅ Installed and used a package
✅ Built a small CSV analysis project
✅ Added automated tests
✅ Uploaded your project to GitHub
That’s a huge milestone.
Where should you go from here?
- Try building a web microproject using Flask (a lightweight web framework).
- Explore pandas for data analysis tasks.
- Write a few automation scripts for your personal life (e.g., renaming files, sending email reminders).
In my next post, I’ll share a beginner-friendly Django + React walkthrough so you can see how backend and frontend development come together.
Closing Thoughts
Learning Python doesn’t have to be overwhelming. By following this step-by-step approach, you can go from knowing nothing about programming to creating a working project in just a few days.
The key is practice. Don’t just read or watch tutorials—type the code, run it, break it, fix it, and learn from the process.
And remember: your first projects don’t have to be perfect. They just have to be finished. Every script you write builds momentum, and before long, you’ll look back and be amazed at how far you’ve come.
So go ahead — install Python today and build your first script. Then share it on GitHub and start your journey as a Python programmer.
Suggested tags: #Python #Tutorial #Beginner #SoftwareEngineering