AI ProgrammingAcademy
Back to Samples

Optional Math: Algebra and Functions

Treat a formula as a recipe: put numbers in, follow a few steps, and interpret the result. Optional support only—not a prerequisite for exams or certificates.

Learning Objectives

  • Understand variables

    Read letters as named numbers rather than unfamiliar symbols.

  • Substitute into a formula

    Work through a simple linear prediction one operation at a time.

  • Read a graph

    Connect an input on the horizontal axis to an output on the vertical axis.

Core Concepts

1. A variable is a named value

In y = 2x + 1, x is the input and y is the output. The mathematical notation 2x means 2 multiplied by x. For x = 3, calculate 2 × 3 + 1 = 7. Python requires the multiplication symbol explicitly.

x = 3
y = 2 * x + 1
print(y)  # 7

2. A function is a repeatable recipe

A function maps an input to an output. f(x) is read “f of x”; it does not mean f multiplied by x. This recipe doubles its input and adds one.

def predict(x):
    return 2 * x + 1

print(predict(0))  # 1
print(predict(3))  # 7

3. Read slope and intercept

In y = mx + b, m is the slope: how much y changes when x increases by one. b is the intercept: the output when x is zero. With m = 2 and b = 1, the points (0, 1), (1, 3) and (2, 5) form a straight line. Negative slopes go down as inputs increase.

for x in [0, 1, 2]:
    print(x, 2 * x + 1)
# input output
# 0     1
# 1     3
# 2     5

4. Rearrange by undoing operations

To solve 2x + 1 = 7, subtract 1 from both sides to get 2x = 6, then divide both sides by 2 to get x = 3. Keep both sides balanced. A programming assignment such as x = 3 stores a value; it is not an equation-solving command.

When this helps: Formulas appear in programming first. Linear models and graph interpretation become especially useful in Professional machine learning.

Practice Exercise

Estimate a delivery time

A toy estimate uses minutes = 3 × distance + 5. For a distance of 4 km, calculate the time and then the extra time for one more kilometre. This is an arithmetic example, not a real delivery model.
distance = 4
# Calculate the estimate
# Compare with distance + 1
# Print the estimate and the difference

Concept Quiz

Test your understanding with this quiz. Select the best answer for each question.

1. In y = 3x + 5, what is the output when x = 0?

2. What does a slope of -2 mean?

Are there any issues that Customer Support should be aware of?

Help optimize our AI programming lessons to ensure student success!

Sign in to send a comment to Customer Support.

Hide Icons