NumPy - Creating ArraysWhat does the function np.random.rand(3, 2) do in NumPy?ACreates a 3x2 array with random floats between 0 and 1BCreates a 3x2 array filled with zerosCCreates a 3x2 array with random integersDCreates a 3x2 array filled with onesCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand np.random.rand() functionThis function generates random floats between 0 and 1.Step 2: Analyze the shape arguments (3, 2)The arguments specify the shape of the output array as 3 rows and 2 columns.Final Answer:Creates a 3x2 array with random floats between 0 and 1 -> Option AQuick Check:np.random.rand(3, 2) = 3x2 random floats [OK]Quick Trick: Remember rand() outputs floats in [0,1) with given shape [OK]Common Mistakes:Thinking it creates integers instead of floatsConfusing shape arguments with array valuesAssuming it creates zeros or ones
Master "Creating Arrays" in NumPy9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More NumPy Quizzes Array Data Types - Complex number type - Quiz 5medium Array Manipulation - flatten() and ravel() for 1D conversion - Quiz 3easy Broadcasting - Broadcasting errors and debugging - Quiz 5medium Broadcasting - Common broadcasting patterns - Quiz 14medium Creating Arrays - np.arange() for range arrays - Quiz 11easy Creating Arrays - np.array() from Python lists - Quiz 10hard Creating Arrays - np.array() from Python lists - Quiz 15hard Indexing and Slicing - Why indexing matters - Quiz 9hard NumPy Fundamentals - Why NumPy over Python lists - Quiz 14medium NumPy Fundamentals - Array attributes (shape, dtype, ndim, size) - Quiz 12easy