Training and prediction, as a real loop
A model that "learns" does not have its answers written by hand. Training means computing parameters from labeled examples. Prediction means applying those learned parameters to a new input the model has never seen.
Here is the smallest honest example. Each labeled example is (feature, label). We learn a single parameter — a threshold — by finding the midpoint between the average feature value of the positive examples and the average of the negative examples. That midpoint is the decision boundary the data implies.
threshold = (mean(positives) + mean(negatives)) / 2
predict(x) = 1 if x >= threshold else 0
The key property: the threshold is derived from the data. Feed it different examples and the threshold moves. That is what separates training from a hardcoded rules = {...} lookup — a lookup gives the same answer no matter what the data says, so it never learns anything.
Real training loops (gradient descent, tree splits) are fancier, but they all share this shape: look at labeled data, adjust parameters to fit it, then predict with those parameters.