Quiz di AI & Machine Learning: NumPy Broadcasting & Vectorization

Broadcasting lets NumPy combine arrays of different shapes without loops, and it is behind most feature scaling and distance code in machine learning. This quiz tests the broadcasting rules, the shapes they produce and the errors you get when shapes do not line up.

Medio 10 domande ~6 minuti Superato con il 80%

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 10

What does this print?

import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]])
b = np.array([10, 20, 30])
print((a + b).tolist())
Mostra la risposta

A. [[11, 22, 33], [14, 25, 36]] b has shape (3,), which matches the last dimension of a (2, 3), so it is added to every row. Adding a different number to each row would need a column of shape (2, 1).

Cosa copre questo quiz

  • The broadcasting rule, compared from the trailing dimension
  • Row vectors, column vectors and the shapes they make
  • Centering data with X - X.mean(axis=0)
  • np.where() instead of an if inside a loop
  • Why in-place operations can fail on integer arrays

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.