NumPy - Fundamentals
You have two datasets each containing 10 million integers: one is a Python list, the other a NumPy array. You want to calculate the mean of each dataset efficiently. Which method is best and why?
sum() and len() on a large list is slower due to Python-level iteration.np.mean() uses optimized C code and vectorized operations, making it faster on large arrays.np.mean() on the NumPy array because it uses optimized C routines and vectorized operations -> Option A15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions