NumPy - Array OperationsWhy does NumPy promote an int32 and a float32 array to float64 during an operation instead of float32?ABecause float32 is not supported in operationsBTo prevent precision loss during mixed operationsCDue to a bug in NumPy's type promotionDBecause int32 always promotes to float64Check Answer
Step-by-Step SolutionSolution:Step 1: Understand type promotion rationaleNumPy promotes types to avoid losing precision in calculations.Step 2: Apply to int32 and float32 casePromoting to float64 ensures no precision loss when mixing int32 and float32.Final Answer:To prevent precision loss during mixed operations -> Option BQuick Check:Promotion prevents precision loss [OK]Quick Trick: Promotion aims to keep precision safe [OK]Common Mistakes:Thinking float32 is unsupportedBlaming bugs for promotionAssuming int32 always promotes to float64
Master "Array Operations" in NumPy9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More NumPy Quizzes Aggregation Functions - np.mean() for average - Quiz 10hard Aggregation Functions - np.std() and np.var() for spread - Quiz 12easy Array Data Types - Type casting with astype() - Quiz 1easy Array Data Types - Boolean type - Quiz 2easy Array Manipulation - np.concatenate() for joining arrays - Quiz 12easy Broadcasting - Broadcasting compatibility check - Quiz 5medium Creating Arrays - np.random.rand() and random arrays - Quiz 5medium Indexing and Slicing - Single element access - Quiz 2easy Indexing and Slicing - Single element access - Quiz 13medium NumPy Fundamentals - Array attributes (shape, dtype, ndim, size) - Quiz 10hard