AI & Machine Learning-Quiz: 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.

Mittel 10 Fragen ~6 Minuten Bestanden ab 80%

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 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())
Lösung zeigen

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).

Darum geht es in diesem 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

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.