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.

Reuse your Python setup, then create five files

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.

Prerequisite setup

Confirm Python and VS Code are ready

If you have not installed them, complete the installation instructions at the beginning of Project 02 first.

Open Python Setup
Part A

Create and open the folder

Keep every Project 03 file together so Python can import the recommendation rules.

  1. Create a folder named project-03-learning-path-recommender.
  2. Open VS Code and select File → Open Folder.
  3. Select the folder you created.
  4. To create a file manually, select the New File icon in the Explorer panel and enter the complete filename, such as rules.py.
  5. Open a VS Code terminal and run python --version. On some Windows systems, use py --version.
  6. Use Python: Select Interpreter if VS Code has not selected your installed Python version.
Part B

Download all five files

Download the Starter Files below and move them into the main project folder.

app.pyCollects learner input and displays the resultrules.pyContains the recommendation function and rulestest_recommender.pyChecks important recommendations automaticallyREADME-template.pdfRename to README.mdproject-checklist.txtTracks final completion evidence
Keep the Python files together

app.py and test_recommender.py import code from rules.py. They will fail if rules.py is renamed or stored in another folder.

Part C

Review and run the downloaded code

Read downloaded code before allowing VS Code to execute it. Then use the terminal inside the project folder.

VS Code terminal
python app.py
python test_recommender.py

Ready to begin when: app.py asks for the learner’s experience and test_recommender.py prints All tests passed.

Recommended project workflow

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.

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 information↓If–then rules↓Recommended lesson↓Reason↓Learner 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.

Start Project 04