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.
Read letters as named numbers rather than unfamiliar symbols.
Work through a simple linear prediction one operation at a time.
Connect an input on the horizontal axis to an output on the vertical axis.
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) # 7A 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)) # 7In 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 5To 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.
distance = 4 # Calculate the estimate # Compare with distance + 1 # Print the estimate and the difference
Test your understanding with this quiz. Select the best answer for each question.
Help optimize our AI programming lessons to ensure student success!
Sign in to send a comment to Customer Support.