Chapter 6 of 33
Day 1 · Key Terms and Part 3: Check Yourself
Key Terms of Day 1 Come back to this table whenever a word feels unfamiliar. | Term | Plain-English meaning | | --- | --- | | Variable | A name that points to a stored value | | Type | The kind of value: int, float, str
Key Terms of Day 1
Come back to this table whenever a word feels unfamiliar.
| Term | Plain-English meaning |
|---|---|
| Variable | A name that points to a stored value |
| Type | The kind of value: int, float, str, bool |
| List / tuple | Ordered values; a list can change, a tuple cannot |
| Dictionary | Key → value lookup table |
| Function | A named, reusable block of code that can return a result |
| Term | Plain-English meaning |
|---|---|
| Class / object | A blueprint / one thing built from it |
| Exception | An error raised while the program runs |
| Virtual environment | An isolated Python setup for one project |
| Percentage | Part ÷ whole × 100 |
| Mean | Sum ÷ count |
| Vector | A list of numbers |
| Matrix | A grid of numbers (rows × columns) |
| Shape | (rows, columns) of an array |
| Dot product | Multiply matching entries, then add |
| Variance | Average squared distance from the mean |
| Standard deviation | Square root of the variance |
| Probability | A number from 0 to 1 for how likely an event is |
| Derivative | The slope of a function at one point |
| Gradient | The list of slopes, one per input |
| Learning rate | How big each gradient-descent step is |
Part 3 — Check Yourself
Answers to the quick prerequisite test
| # | Question | Answer |
|---|---|---|
| 1 | Can you write and call a Python function? | def add(a, b): return a + b then add(2, 3) gives 5. |
| 2 | Can you loop through a list and access a dictionary value? | for x in [1,2,3]: print(x) and d = {"lr": 0.1}; d["lr"] gives 0.1. |
| 3 | Can you explain what a 2×3 matrix means? | 2 rows and 3 columns, 6 numbers in total. In ML: 2 examples with 3 features each. |
| # | Question | Answer |
|---|---|---|
| 4 | Can you multiply two compatible matrix shapes on paper? | Check the inner numbers match, then take row·column dot products. (2×3)·(3×2) → 2×2. |
| 5 | Can you calculate a simple average? | Add everything, divide by how many. [3, 5, 10] → 18 ÷ 3 = 6. |
| 6 | Can you read a Python error and locate the failing line? | Read the last line for the what, then find the last File ... line N above it for the where. |
Ten-minute practice
Try these before looking at the answers.
- Write
def is_even(n)that returns True for even numbers. - Given
scores = [80, 90, 70], compute the mean with a function you write yourself. - What is the shape of a matrix with 5 examples and 8 features? What is the shape of (5×8)·(8×3)?
- What is the dot product of [2, 0, 1] and [3, 5, 4]?
- A model predicts 18 of 20 correctly. What is its accuracy?
- If f(w) = w² and w = 5, what is the slope? Which direction should w move to reduce f?
Answers, step by step
return n % 2 == 0. The remainder of an even number divided by 2 is 0, so the comparison gives True.sum(scores) / len(scores): 80 + 90 + 70 = 240, then 240 ÷ 3 = 80.0.- 5×8. The inner numbers of (5×8)·(8×3) are both 8, so they match and disappear: the result is 5×3.
- 2×3 + 0×5 + 1×4 = 6 + 0 + 4 = 10.
- 18 ÷ 20 = 0.90 = 90%.
- Slope = 2w = 10 (positive), so f rises as w grows. Move w down: subtract the slope × a small learning rate.
Most common beginner mistakes
- Forgetting that Python counts from 0, and that a slice
a[1:3]stops before index 3. - Confusing a matrix's rows (examples) with its columns (features).
- Trying to multiply matrices whose inner shapes do not match. Always write the shapes down first.
- Skimming instead of typing the code. Run every snippet, then change a number and predict the new output.
- Trying to master all the math first. Learn the minimum, start Day 2, and return to the math when it shows up in code.
Ready? If you can do the six practice questions without looking, you are ready for Day 2. If two or more felt hard, repeat the worked problems above and then try again. It will save you time later.