← Quiz: NumPy: all 10 questions
Quiz: NumPy · Question 6 of 10
What does this print? (code)
What does this print?
import numpy as np
a = np.array([[1, 2], [3, 4], [5, 6]])
print(a.shape, a.sum(axis=0))
- A.(2, 3) [3 7 11]
- B.(3, 2) [ 9 12]
- C.(3, 2) [ 3 7 11]
- D.(3, 2) 21
Answer & explanation
Correct answer: (3, 2) [ 9 12]
3 rows and 2 columns; axis=0 adds down each column.
Can you get the rest right without peeking?
Take the timed Quiz: NumPy quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →