Beginner Project • Basic Python

Rule-Based Learning
Path Recommender

Use clear if–then rules to recommend a learner’s next suitable Ai lesson and explain every decision.

0% complete
Your work is saved automatically.Complete the planning fields below. Your answers stay in this browser.

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.

Learner inputIf–then rulesRecommendationDecision explanationUser choice
Rule-Based AiPython conditionsFunctionsUser inputRecommendation logicExplainable decisionsBasic testing
LevelBeginner
CodingBasic Python
Time60–90 minutes
SoftwarePython and VS Code
ComputerNormal laptop; no GPU

Build the recommender

Create the learner profile, recommendation rules, command-line interface and tests.

Step 01

Define the learner information

Decide which limited information the rules need.

ExperienceBeginnerGoalMachine LearningPython knowledgeNoCompleted topicAi Foundations
Step 02

Create the recommendation function

Place the ordered if–then rules inside rules.py.

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."
Why rule order matters

The first matching rule returns the recommendation. Foundation and prerequisite checks should therefore appear before specialization rules.

Step 03

Create the user interface

Collect input safely and display both the lesson and reason.

app.py — essential flow
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)
Run the programpython app.py
Input safety

Use the supplied get_yes_no() function in the complete starter file so invalid answers are requested again.

Step 04

Test different learners

Confirm that different profiles follow the intended rules.

Test case 1
Experience
Beginner
Goal
Machine Learning
Python
No
Completed
Ai Foundations
Expected: Python Foundations
Test case 2
Experience
Beginner
Goal
Machine Learning
Python
Yes
Completed
Ai Foundations, Data Preparation
Expected: Supervised Learning Basics
Step 05

Add automated tests

Use assertions to check the recommendation function automatically.

test_recommender.py
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.")
Run the testspython test_recommender.py
Expected result

All tests passed.

Learner informationIf–then rulesRecommended lessonReasonLearner accepts or chooses another

Complete your recommender

Working Python recommenderAt least five rulesExplanation for every resultTwo or more test casesREADME file

Responsible Ai check

Confirm your working project

Portfolio explanation

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.

Next project

Project 04 — Spam Message Classifier

Move from human-defined rules to a model that learns patterns from labelled examples.

View Project Path