ZMedia Purwodadi

Python Tutorial for Beginners: Step by Step

Table of Contents

You've decided to learn Python. Good decision. Now you need a tutorial that actually works, one that doesn't assume you already know what a variable is, doesn't skip important steps, and doesn't waste your time with theory before you've written a single line of code.

This is that tutorial.

By the end of this guide, you'll understand the core building blocks of Python programming, know how to write and run Python code on your own computer, and have the foundation to go further whether your goal is data analysis, automation, web development, or landing a tech job in Nigeria.

Let's go step by step.

What is Python?

Python is a programming language, a tool that lets you give instructions to a computer. What makes Python special for beginners is that its syntax (the rules for writing code) is clean and readable. It looks closer to English than most other languages, which means you spend less time fighting the language and more time learning to think like a programmer.

Here's a taste. This is a complete, working Python program:

print("Hello! Welcome to Python.")

That's it. One line. It runs. Compare that to languages like Java or C++, where the same thing requires 5–10 lines of setup before you can print anything. Python gets out of your way so you can focus on learning.

Step 1: Set Up Python on Your Computer

Before writing code, you need Python installed on your machine. Here's how:

Download Python

  1. Go to python.org/downloads
  2. Click the yellow "Download Python 3.x.x" button
  3. Run the installer once it downloads
  4. Important: On the first screen of the installer, tick the checkbox that says "Add Python to PATH" before clicking Install Now. If you miss this step, Python won't work from your command line.

Verify the Installation

Open Command Prompt on Windows (search "cmd" in your Start menu) and type:

python --version

You should see something like this Python 3.12.3. If you do, Python is installed correctly.

Install VS Code (Your Code Editor)

You'll write Python code in a code editor. Download VS Code for free at code.visualstudio.com. After installing:

  1. Open VS Code
  2. Click the Extensions icon on the left sidebar
  3. Search "Python" and install the Microsoft Python extension

You're set up. Let's write code.

Step 2: Your First Python Program

In VS Code, create a new file called first_program.py and type this:

print("Hello, Nigeria!")
print("I am learning Python.")
print("This is my first program.")

To run it, open the VS Code terminal (View → Terminal) and type:

python first_program.py

You should see three lines of output. Congratulations, you just wrote and ran your first Python program.

Step 3: Variables: Storing Information

A variable is a container that stores a value. Think of it like a labelled box you put something in it and refer to it by name.

name = "Amina"
age = 22
city = "Lagos"
has_laptop = True

print(name)
print(age)
print(city)

Python automatically figures out what type of data you're storing:

  • "Amina"  a string (text, always in quotes)
  • 22 an integer (whole number)
  • True / False a boolean (yes or no value)
  • 3.5 a float (decimal number)

You can do maths with numbers:

price = 5000
discount = 500
final_price = price - discount

print(f"You pay: ₦{final_price}")

The f"..." syntax is called an f-string it lets you insert variable values directly inside a string. Very useful.

Step 4: Getting Input from the User

Programs become interesting when they can respond to the user. Use input() to collect typed input:

name = input("Enter your name: ")
print(f"Welcome, {name}! Let's learn Python together.")

Run this program and type your name when prompted. The program greets you back with your name. Simple but this is the foundation of interactive programs.

Step 5: Making Decisions with If Statements

Real programs need to make decisions. The if statement lets you run different code depending on a condition.

score = int(input("Enter your test score: "))

if score >= 70:
    print("Congratulations! You passed.")
elif score >= 50:
    print("You almost made it. Keep practising.")
else:
    print("Don't give up. Try again.")

Notice the structure:

  • if checks the first condition
  • elif checks another condition if the first was False
  • else runs if none of the above conditions were True

Also notice the indentation (spaces before each print). Python uses indentation to define blocks of code. Get this wrong and your code will break.

Step 6: Loops: Repeating Actions

Loops let you repeat an action multiple times without rewriting the same code.

The For Loop

fruits = ["mango", "pineapple", "banana", "pawpaw"]

for fruit in fruits:
    print(f"I like {fruit}")

This loops through each item in the list and prints it. Output:

I like mango
I like pineapple
I like banana
I like pawpaw

The While Loop

count = 1

while count <= 5:
    print(f"Count: {count}")
    count += 1

This keeps running as long as count is 5 or less. Be careful with while loops if your condition never becomes False, the loop runs forever (an infinite loop).

Step 7: Lists Storing Multiple Values

A list stores multiple values in a single variable.

students = ["Chukwudi", "Fatima", "Emeka", "Blessing"]

print(students[0])   # Chukwudi (index starts at 0)
print(students[2])   # Emeka
print(len(students)) # 4 (number of items)

students.append("Kemi")  # Add a new student
print(students)

Lists are one of the most used data structures in Python. You'll work with them constantly in data analysis, web development, and almost every other Python application.

Step 8: Dictionaries Key-Value Data

A dictionary stores data as key-value pairs like a real dictionary where a word (key) maps to its meaning (value).

student = {
    "name": "Ngozi",
    "age": 20,
    "state": "Enugu",
    "score": 85
}

print(student["name"])   # Ngozi
print(student["score"])  # 85

student["grade"] = "A"   # Add a new key-value pair
print(student)

Dictionaries are perfect for representing real-world objects a student, a product, a user profile, and a transaction record.

Step 9: Functions: Reusable Code Blocks

A function is a block of code you define once and can use as many times as you need.

def calculate_grade(score):
    if score >= 70:
        return "A"
    elif score >= 60:
        return "B"
    elif score >= 50:
        return "C"
    else:
        return "F"

print(calculate_grade(85))   # A
print(calculate_grade(62))   # B
print(calculate_grade(45))   # F

Functions are the foundation of writing clean, organised code. Instead of repeating the same logic in ten places, you write it once in a function and call it wherever needed.

Step 10: Putting It All Together Build a Mini Project

Now let's combine everything you've learned into a real mini project: a student grade calculator.

def calculate_grade(score):
    if score >= 70:
        return "A"
    elif score >= 60:
        return "B"
    elif score >= 50:
        return "C"
    elif score >= 40:
        return "D"
    else:
        return "F"

students = []
num_students = int(input("How many students? "))

for i in range(num_students):
    name = input(f"Enter name of student {i + 1}: ")
    score = int(input(f"Enter score for {name}: "))
    grade = calculate_grade(score)
    students.append({"name": name, "score": score, "grade": grade})

print("\n--- Results ---")
for student in students:
    print(f"{student['name']}: {student['score']} → Grade {student['grade']}")

Run this, enter 3–5 student names and scores, and watch it calculate grades automatically. This single project uses variables, input, if/elif/else, loops, lists, dictionaries, and functions — everything you've learned in this tutorial.

What to Learn Next

You've covered the core fundamentals. Here's where to go from here depending on your goal:

  • Data Analysis: Learn Pandas, NumPy, and Matplotlib — the tools Nigerian data analysts use daily
  • Web Development: Learn Django or FastAPI to build web applications
  • Machine Learning: Learn Scikit-learn to build predictive models
  • Automation: Learn to scrape websites, automate files, and build bots

Whatever path you choose, the fundamentals you've just learned are the foundation. Everything else builds on top of this.

The Fastest Way to Get Better: Practice with Exercises

Tutorials teach you concepts. Exercises build actual skill. The difference between a Nigerian developer who gets hired and one who stays stuck watching tutorials is simple: the one who gets hired practiced relentlessly.

At JacobIsah Programming Hub, we've built the Python Exercises Workbook a structured collection of 100+ hands-on Python exercises specifically designed for beginners. Every concept in this tutorial (variables, loops, functions, lists, dictionaries) has dedicated practice problems, each with full solutions so you can check your work and understand your mistakes.

It's the practice tool we wish existed when we were learning Python in Nigeria.

👉 Get the Python Exercises Workbook on Selar →

And if you're ready to go beyond exercises and fully master Python for data analysis from Pandas to real-world projects our Data Analysis Course takes you from beginner to job-ready step by step, with Nigerian datasets, practical projects, and direct mentorship support.

👉 Explore all courses at jacobisah.selar.com →

Conclusion

You just completed a full Python tutorial for beginners. You installed Python, wrote your first program, and learned variables, input, if statements, loops, lists, dictionaries, and functions. You built a working mini project.

That's more than most people who say they want to learn Python ever actually do.

The next step is practice. Don't let this knowledge sit idle. Open VS Code right now and build something, anything. A calculator. A quiz. A simple expense tracker. The more you build, the faster you grow.

And when you're ready for structured guidance, exercises, and a proven learning path, JacobIsah Programming Hub is here for you.

— Jacob Isah | JacobIsah Programming Hub | Lagos, Nigeria

Teaching Nigerians to go from Beginner to Builder, one line of code at a time.

Post a Comment