NumPy - Creating ArraysWhich of the following best describes the output of np.zeros((2, 2)) in NumPy?AA 2x2 array filled with zerosBA 1D array with two zerosCAn array with uninitialized valuesDA 2x2 array filled with onesCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand np.zeros()The function creates an array filled with zeros.Step 2: Check the shape argumentThe shape (2, 2) means a 2D array with 2 rows and 2 columns.Final Answer:A 2x2 array filled with zeros -> Option AQuick Check:Shape matches 2D zero array [OK]Quick Trick: np.zeros(shape) creates zero array of given shape [OK]Common Mistakes:Confusing shape tuple with single integerExpecting ones instead of zerosAssuming 1D array when shape is 2D
Master "Creating Arrays" in NumPy9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More NumPy Quizzes Aggregation Functions - np.std() and np.var() for spread - Quiz 1easy Aggregation Functions - np.min() and np.max() - Quiz 2easy Aggregation Functions - np.prod() for product - Quiz 10hard Aggregation Functions - np.std() and np.var() for spread - Quiz 6medium Aggregation Functions - np.mean() for average - Quiz 8hard Array Data Types - Boolean type - Quiz 13medium Array Operations - Element-wise arithmetic - Quiz 5medium Broadcasting - Why broadcasting matters - Quiz 3easy Broadcasting - 1D and 2D broadcasting - Quiz 3easy Creating Arrays - np.arange() for range arrays - Quiz 7medium