An explainable lesson recommender
Create a Python program that asks about a learner’s experience, goal, Python knowledge and completed topics, then recommends a suitable next lesson.
Use clear if–then rules to recommend a learner’s next suitable Ai lesson and explain every decision.
This project uses the Python and VS Code setup introduced in Project 02. You do not need to install pandas, matplotlib or any other library.
If you have not installed them, complete the installation instructions at the beginning of Project 02 first.
Keep every Project 03 file together so Python can import the recommendation rules.
project-03-learning-path-recommender.rules.py.python --version. On some Windows systems, use py --version.Download the Starter Files below and move them into the main project folder.
README.mdproject-checklist.txtTracks final completion evidenceapp.py and test_recommender.py import code from rules.py. They will fail if rules.py is renamed or stored in another folder.
Read downloaded code before allowing VS Code to execute it. Then use the terminal inside the project folder.
python app.py
python test_recommender.pyReady to begin when: app.py asks for the learner’s experience and test_recommender.py prints All tests passed.
Read one guided step → edit the relevant file → save with Ctrl + S → run the program → compare the result → mark the checkpoint only when it works.
Create a Python program that asks about a learner’s experience, goal, Python knowledge and completed topics, then recommends a suitable next lesson.
project-03-learning-path-recommender/
├── app.py
├── rules.py
├── test_recommender.py
├── README.md
└── project-checklist.txtCreate the learner profile, recommendation rules, command-line interface and tests.
Decide which limited information the rules need.
Place the ordered if–then rules inside rules.py.
def recommend_lesson(
experience: str,
goal: str,
knows_python: bool,
completed_topics: list[str],
) -> tuple[str, str]:
"""Recommend the next lesson and explain the decision."""
experience = experience.strip().lower()
goal = goal.strip().lower()
completed = {topic.strip().lower() for topic in completed_topics}
if experience == "beginner" and "ai foundations" not in completed:
return "Ai Foundations", "Start with the basic concepts first."
if not knows_python:
return "Python Foundations", "Python is needed for practical projects."
if goal == "machine learning" and "data preparation" not in completed:
return "Data Preparation", "Machine Learning requires clean data."
if goal == "machine learning":
return "Supervised Learning Basics", "You are ready for ML basics."
if goal == "generative ai":
return "Prompt Engineering", "Start with structured model interaction."
if goal == "computer vision":
return "Image Classification Basics", "Start with a core vision task."
return "Ai Applications Overview", "Explore the main application areas."The first matching rule returns the recommendation. Foundation and prerequisite checks should therefore appear before specialization rules.
Collect input safely and display both the lesson and reason.
from rules import recommend_lesson
experience = input("Experience level: ")
goal = input("Learning goal: ")
knows_python = get_yes_no("Do you know basic Python? Yes/No: ")
completed_text = input("Completed topics, separated by commas: ")
completed_topics = [topic.strip() for topic in completed_text.split(",") if topic.strip()]
lesson, reason = recommend_lesson(
experience, goal, knows_python, completed_topics
)
print("\nRecommended next lesson:", lesson)
print("Reason:", reason)python app.pyUse the supplied get_yes_no() function in the complete starter file so invalid answers are requested again.
Confirm that different profiles follow the intended rules.
Use assertions to check the recommendation function automatically.
from rules import recommend_lesson
lesson, _ = recommend_lesson(
experience="Beginner",
goal="Machine Learning",
knows_python=False,
completed_topics=["Ai Foundations"],
)
assert lesson == "Python Foundations"
lesson, _ = recommend_lesson(
experience="Beginner",
goal="Machine Learning",
knows_python=True,
completed_topics=["Ai Foundations", "Data Preparation"],
)
assert lesson == "Supervised Learning Basics"
print("All tests passed.")python test_recommender.pyAll tests passed.
I built a Rule-Based Learning Path Recommender using Python. The system collects a learner’s experience, goal, Python knowledge and completed topics, then applies explainable if–then rules to recommend the next lesson. I also added input validation, decision explanations and automated tests.