PEF logo Pitafi Education FoundationEducation for a better future ← Back to home

PEF · Free online learning

Classical AI Foundations with Python

Learn how intelligent systems represent problems, explore possible solutions, and reason with rules. Turn the foundations of classical artificial intelligence into practical Python programs.

Foundational levelPython-based practice5 learning topics

Your learning journey

Understand the ideas behind intelligent decisions

Classical AI focuses on explicit representations, search, and reasoning. This course introduces these ideas through small problems you can model and solve in Python, from finding a route to checking whether a set of rules can be satisfied.

Who this course is for

Students and curious learners who want to understand how AI algorithms work. You should be comfortable with basic Python variables, loops, functions, and lists. No prior AI experience is required.

What you will learn

  • Describe a problem using states, actions, and goals.
  • Use search to find paths through a problem space.
  • Represent facts and reason with simple rules.
  • Solve problems with constraints and backtracking.

Before you begin

Have Python 3 and a code editor or notebook ready. The introductory example below uses only the Python standard library. Keep a notebook of your assumptions, test cases, and observations as you work.

Topic 1 · Overview & materials

Introduction to AI

Start with the course learning objectives, a definition of artificial intelligence, and the major domains of AI. Explore how these capabilities work together in an AI system, then use the notes and slides below to review the topic.

Download notes & materials

Topic 2 · Overview & materials

Python for AI

Explore Python data structures for representing AI problems. Practice using dictionaries for connections, sets for visited states, and queues for states waiting to be explored.

Download notes & materials

Downloadable materials for this topic will be added here.

Topic 3 · Overview & materials

Search algorithms

Learn how search algorithms explore possible solutions. Compare breadth-first and depth-first search, then consider how costs and heuristics guide the search for a useful route.

Download notes & materials

Downloadable materials for this topic will be added here.

Topic 4 · Overview & materials

Knowledge & logic

Learn how an AI system represents facts and uses rules to draw conclusions. Practice expressing simple conditions and checking their behavior with truth tables.

Download notes & materials

Downloadable materials for this topic will be added here.

Topic 5 · Overview & materials

Constraint satisfaction

Describe problems using variables, possible values, and constraints. Explore how backtracking searches for a valid assignment and apply these ideas to a map-coloring problem.

Download notes & materials

Downloadable materials for this topic will be added here.

Topic 1: Introduction to AI · Subtopic 1.1

Course Overview & Learning Objectives

Begin with the purpose of this course and the skills you will develop. Explore how classical AI uses problem representation, search, and reasoning to build systems that work toward a goal.

Watch on YouTube (opens in a new tab)

Learning objectives

  • Explain what artificial intelligence studies and identify examples of AI tasks.
  • Recognize the major domains of AI and the capabilities they contribute.
  • Connect foundational AI ideas to practical problem solving in Python.
Reflect and apply

Choose one task you would like to solve with AI. Write down what a successful solution would do and which skills you hope to gain from this course.

Topic 1: Introduction to AI · Subtopic 1.2

What Is Artificial Intelligence?

Artificial intelligence is the study and development of computational systems that perform tasks involving capabilities such as reasoning, learning, perception, and decision making. An agent-based view describes a system that observes its environment and selects actions to achieve objectives.

Watch on YouTube (opens in a new tab)

Key ideas

  • Identify an agent, its environment, the information it receives, and its possible actions.
  • Distinguish a system designed for a specific task from the broader ambition of general intelligence.
  • Describe an AI task in terms of goals and measurable outcomes.
Reflect and apply

Consider a route-planning assistant. Identify its inputs, available choices, and goal. How would you measure whether its route is useful?

Topic 1: Introduction to AI · Subtopic 1.3

Major Domains of AI

AI includes several overlapping areas. Each addresses a different part of intelligent behavior, from representing facts and finding solutions to interpreting language and visual information.

Watch on YouTube (opens in a new tab)

Key ideas

  • Search and planning explore possible actions and routes toward a goal.
  • Knowledge representation and reasoning organize facts and draw conclusions.
  • Machine learning develops patterns or predictive models from data.
  • Natural language processing and computer vision work with language and visual information; robotics combines sensing and action in the physical world.
Reflect and apply

Choose three applications, such as a maze solver, a translation tool, and a robot. Identify the AI domains each might use and explain your choices.

Topic 1: Introduction to AI · Subtopic 1.4

How AI Domains Work Together

An AI system may combine several capabilities to complete a task. Understanding how information moves between them helps you connect individual algorithms to the behavior of the whole system.

Watch on YouTube (opens in a new tab)

Key ideas

  • Perception turns input, such as images or sensor readings, into useful information.
  • Knowledge and reasoning provide context for interpreting that information.
  • Planning and decision making choose actions that support the system's objective.
  • Learning can improve components using data, while evaluation checks whether the system meets its goals.
Reflect and apply

Sketch a delivery robot as a sequence of steps: sense its surroundings, represent obstacles, plan a route, and move. Label the AI domains involved and describe what could happen if one step produces an incorrect result.

Topic 02

Python for AI

Choose data structures that make your problem easy to explore. A dictionary can map each location to its neighbors, a set can record visited states, and a queue can hold states waiting to be explored.

graph = {
    "A": ["B", "C"],
    "B": ["D"],
    "C": ["D"],
    "D": []
}

for neighbor in graph["A"]:
    print("Possible next state:", neighbor)
Try it: model a small map

Add a location E and connect it to D. If travel is possible in both directions, remember to include both connections. Write a function that returns the neighbors of a location.

Topic 04

Knowledge & logic

A knowledge-based system represents facts and uses rules to derive conclusions. In propositional logic, statements are true or false, and connectives such as AND, OR, and NOT combine them.

For example, the rule “if it rains, the ground is wet” and the fact “it rains” support the conclusion “the ground is wet.” Wet ground alone does not establish that it rained; there may be other causes.

Try it: reason with rules

Represent “has a library card” and “has overdue books” as Boolean values. Define borrowing permission as having a card AND having no overdue books. Check all four combinations in a truth table.

Topic 05

Constraint satisfaction

A constraint satisfaction problem has variables, a domain of possible values for each variable, and constraints limiting which assignments can coexist. Timetabling, map coloring, and Sudoku can all be described this way.

Backtracking builds an assignment step by step. If a choice violates a constraint or leads to a dead end, the algorithm undoes that choice and tries another value.

Try it: color a map

Model three regions that all share borders with one another. Assign each a color so that neighboring regions differ. Try two colors, then three. Explain why the first case has no solution.

Put it into practice

Build a Python maze solver

Bring problem representation and search together in a small program that finds a route from a starting cell to an exit.

  1. Represent a grid with open cells, walls, a start, and a goal.
  2. Generate valid neighboring cells without crossing walls or grid boundaries.
  3. Use BFS to find a shortest route when each move has equal cost.
  4. Display the route and handle mazes with no solution.
  5. Describe your representation and test cases in a short project README.

Extend your project: add different terrain costs, then compare uniform-cost search with A*. Record both path cost and the number of explored states.