Minu's Games logo
MINU'S ROBOTICS

A Minu's Games EdTech Lab

← Code & Cognition
Day 18 of 30Real Python & Data

🔢NumPy — Arrays & Vectors

🎯 Today's objective

Work with fast numerical arrays — the math layer of AI.

📖 Key concepts

  • np.array() makes an n-dimensional array
  • Vectorised math (no loops): a * 2
  • Shape, mean, sum, dot product
  • Arrays power tensors in deep learning

💻 Try this code

import numpy as np
a = np.array([1, 2, 3, 4])
print(a * 10)          # [10 20 30 40]
print(a.mean(), a.sum())
print(np.dot(a, a))    # 1+4+9+16 = 30

👥 Learn it your way

🧒 Young Explorers

NumPy lets you do math on a whole list at once — super fast and tidy.

Your task

Make an array of 5 test scores; print the mean and the scores boosted by 5.

💼 Professionals

Vectorise instead of looping; understand shapes/broadcasting — the #1 ML bug source.

Your task

Create a 3×3 array, print its shape, transpose, and column means.

🤖 AI connection

Neural networks ARE arrays of numbers ("tensors") multiplied together. NumPy is the gateway drug to PyTorch/TensorFlow.

✅ Quick check

Why use NumPy over plain lists for math?

It’s faster and lets you do math on whole arrays at once (vectorised).

What is a.mean()?

The average of the array’s values.