Python Tutorial for Beginners: Learn Python Step by Step (With Code Examples)
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, you'll understand Python's core building blocks, know how to write and run 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.
What is Python?
Python is a programming language that lets you give instructions to a computer. Its syntax is clean and readable closer to English than most other languages. Here's a complete, working Python program:
print("Hello! Welcome to Python.")
One line. It runs. Compare that to Java or C++, where the same thing needs 5–10 lines of setup. Python gets out of your way so you can focus on learning.
Step 1: Set Up Python on Your Computer
- Go to python.org/downloads and download Python 3.12+
- Run the installer tick "Add Python to PATH" on the first screen (critical step most beginners miss)
- Verify in Command Prompt:
python --version - Download VS Code as your code editor, then install the Microsoft Python extension
Step 2: Your First Python Program
Create a file called first_program.py in VS Code and type:
print("Hello, Nigeria!")
print("I am learning Python.")
print("This is my first program.")
Run it from the VS Code terminal: python first_program.py. You just wrote and ran your first Python program.
Step 3: Variables Storing Information
A variable is a labelled container that stores a value.
name = "Amina"
age = 22
city = "Lagos"
has_laptop = True
print(f"My name is {name} and I live in {city}.")
Python data types: string (text in quotes), integer (whole number), float (decimal), and boolean (True/False). The f"..." syntax lets you insert variables directly into strings.
Step 4: Getting User Input
name = input("Enter your name: ")
print(f"Welcome, {name}! Let's learn Python together.")
Step 5: If Statements Making Decisions
score = int(input("Enter your test score: "))
if score >= 70:
print("Congratulations! You passed.")
elif score >= 50:
print("Almost. Keep practising.")
else:
print("Don't give up. Try again.")
Note the indentation. Python uses spaces to define code blocks. Get this wrong and your code breaks.
Step 6: Loops Repeating Actions
# For loop
fruits = ["mango", "pineapple", "banana", "pawpaw"]
for fruit in fruits:
print(f"I like {fruit}")
# While loop
count = 1
while count <= 5:
print(f"Count: {count}")
count += 1
Step 7: Lists
students = ["Chukwudi", "Fatima", "Emeka", "Blessing"]
print(students[0]) # Chukwudi (index starts at 0)
print(len(students)) # 4
students.append("Kemi") # Add a new item
Step 8: Dictionaries Key-Value Data
student = {
"name": "Ngozi",
"age": 20,
"state": "Enugu",
"score": 85
}
print(student["name"]) # Ngozi
print(student["score"]) # 85
Step 9: Functions Reusable Code
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(45)) # F
Step 10: Mini Project Student Grade Calculator
Let's combine everything into one working project:
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 = int(input("How many students? "))
for i in range(num):
name = input(f"Name of student {i+1}: ")
score = int(input(f"Score for {name}: "))
students.append({"name": name, "score": score, "grade": calculate_grade(score)})
print("\n--- Results ---")
for s in students:
print(f"{s['name']}: {s['score']} → Grade {s['grade']}")
This one project uses everything: variables, input, if/else, loops, lists, dictionaries, and functions. Build it yourself from scratch.
What to Learn Next
- Data Analysis: Pandas, NumPy, Matplotlib
- Web Development: Django or FastAPI
- Machine Learning: Scikit-learn
- Automation: Web scraping, file automation, bots
The Fastest Way to Improve: Structured Practice
Tutorials teach 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.
The Python Exercises Workbook from JacobIsah Programming Hub gives you 100+ hands-on exercises covering every concept in this tutorial variables, loops, functions, lists, and dictionaries each with full solutions. Built specifically for Nigerian beginners who want to practise, not just watch.
👉 Get the Python Exercises Workbook on Selar →
Ready to go further? Our Data Analysis Course takes you from Python basics to job-ready data analyst with Nigerian datasets, real projects, and mentorship support.
👉 Explore all courses at jacobisah.selar.com →
You Did It
You've completed a full Python beginner tutorial. You installed Python, wrote your first program, and learned variables, input, conditionals, loops, lists, dictionaries, and functions. You built a working project.
Now practice. Open VS Code and build something a calculator, a quiz, a simple expense tracker. The more you build, the faster you grow.
When you're ready for a structured path jacobisah.selar.com has everything you need to go from beginner to builder.
— Jacob Isah | JacobIsah Programming Hub | Lagos, Nigeria
From Beginner to Builder, one line of code at a time.
.jpg)
Post a Comment