QuestionQ29

VerifiedWorking with Data and Performing Simple Analyses

You have gathered sales data and want to calculate the average with the NumPy library.

Which option correctly demonstrates installing NumPy and using it in code to complete this task?

Explanation

The standard and only correct way to install NumPy from the command line is 'pip install numpy' — pip does not support an 'as' aliasing clause the way Python's import statement does, and 'from pip install numpy' is not valid syntax of any kind. Once installed, NumPy is used in Python via 'import numpy as np' (or 'import numpy'), after which np.array() builds an ndarray and np.mean() computes its average — the standard idiom taught in NumPy's official documentation for descriptive statistics.

Community Discussion

No comments yet. Be the first to start the discussion!