Μετάβαση στο κύριο περιεχόμενο
🔒 Λειτουργία προεπισκόπησης. Τα πρώτα δεκαπέντε μαθήματα Foundations είναι δωρεάν· αυτό είναι Pro. Ξεκινήστε ένα 7ήμερο trial για να ξεκλειδώσετε τον επεξεργαστή, τις υποδείξεις AI και το υπόλοιπο του προγράμματος. Απαιτείται κάρτα, ακυρώνετε οποιαδήποτε στιγμή από το Dashboard.Ξεκινήστε 7ήμερο trial →
← ΜαθήματαSenior Deep-DivesModule 2 · CPython performance · RecapΜοτίβα διανυσματοποίησης NumPypredict47 / 161
+125 XP
Εργασία🌐 shown in EN
📝 **Question:** Predict the exact output. Four vectorization patterns in one trace: (1) scalar broadcast \`a * 2\`, (2) scalar add on a 2D matrix, (3) row-broadcast \`m + row\` where the 1D row stretches across both rows of the matrix, (4) boolean mask \`a[a > 2]\`. \`.tolist()\` is used everywhere to keep output stable across NumPy versions. 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
Πρόβλεψε έξοδο

Διάβασε τον κώδικα προσεκτικά

import numpy as np


a = np.array([1, 2, 3, 4])
b = a * 2
print(b.tolist())

m = np.array([[1, 2], [3, 4]])
print((m + 10).tolist())

row = np.array([10, 20])
print((m + row).tolist())

mask = a > 2
print(a[mask].tolist())
print(int(np.sum(a)))

Τι θα εμφανίσει το πρόγραμμα; Γράψε εδώ: