Education & Learning

Machine learning prerequisites: a small Python readiness exercise

Check Python loops, functions, averages and error calculations with an original exercise before paying for an introductory machine learning course.

By SimplyFound · Published and researched 10 October 2026 · Original buying worksheets and source research. Our editorial standards.

The useful starting point

For an introductory machine learning course, being comfortable with Python variables, lists, loops and functions is a useful starting point. Basic arithmetic, algebra and interpreting a graph matter too. Use the exercise below to find preparation gaps; it is a learning checklist, not an admission test or a measure of career readiness.

Try this without copying the answer

Imagine you predict the study time needed for four lessons. Your predicted hours are [2, 3, 3, 4]; actual hours are [1, 4, 2, 5]. Write a function that computes the mean absolute error: add the absolute differences and divide by the number of lessons.

Then explain why each error counts positively, and what happens when predicted and actual lists have different lengths. You do not need a machine learning library for this exercise.

One possible solution

def mean_absolute_error(predicted, actual):
    if len(predicted) != len(actual) or not actual:
        raise ValueError('Use non-empty lists of equal length')
    total = 0
    for guess, observed in zip(predicted, actual):
        total += abs(guess - observed)
    return total / len(actual)

print(mean_absolute_error([2, 3, 3, 4], [1, 4, 2, 5]))
# 1.0 hours

Every prediction differs by one hour, so the mean absolute error is one hour. Change the predictions to the actual values: the error becomes zero. This is an original teaching example from SimplyFound, not a provider assessment.

What your result tells you

If loops and functions were difficult, practise small Python exercises before buying an intensive program. If the code was easy but the average confused you, revise arithmetic and interpreting quantities. If both were comfortable, ask the provider for a sample assignment to check the next level.

Do not treat solving one example as proof that you can complete an entire course. Time availability, English comprehension, persistence and access to a usable computer can matter alongside technical prerequisites.

Build your preparation checklist

Use four short tasks: write a function, transform a list, read a simple line chart, and explain a percentage change. Mark each as ‘independent’, ‘with help’ or ‘not yet’. Work on the last two categories, then repeat with a different example.

Coursera’s introductory specialization names basic coding and school mathematics as prerequisites. Check your chosen provider’s current expectations because other programs may begin at a different level.

Sources and scope

Primary sources consulted on 10 October 2026. Specific sourced facts are attributed in the guide; the shopping worksheets are our own. Details can change, so confirm the terms for your purchase.

Any calculation examples are illustrative, rather than live prices. Check the retailer’s current price, availability and terms. Some product links elsewhere on SimplyFound earn a commission. How affiliate links work.

Suggest a factual correction →

Keep exploring

Finds to research next

These are discovery starting points. Check the retailer or provider’s current details before deciding.