0
0
NumPydata~5 mins

np.sqrt() for square roots in NumPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the function np.sqrt() do in numpy?

np.sqrt() calculates the square root of each element in a numpy array or a single number.

Click to reveal answer
beginner
How do you calculate the square root of 16 using numpy?

You use np.sqrt(16), which returns 4.0.

Click to reveal answer
beginner
Can np.sqrt() handle arrays? Give an example.

Yes, it can. For example, np.sqrt(np.array([1, 4, 9])) returns [1. 2. 3.].

Click to reveal answer
intermediate
What happens if you use np.sqrt() on a negative number?

It returns nan (not a number) and raises a warning because square root of negative numbers is not defined in real numbers.

Click to reveal answer
beginner
Why is np.sqrt() useful in data science?

It helps to transform data, calculate distances, or normalize values by finding square roots quickly and efficiently.

Click to reveal answer
What is the output of np.sqrt(25)?
A25
B5.0
C12.5
DError
Which of these inputs can np.sqrt() accept?
ASingle numbers and numpy arrays
BOnly lists
COnly single numbers
DOnly strings
What does np.sqrt(np.array([4, 16, 36])) return?
A[1 2 3]
B[4 16 36]
C[2. 4. 6.]
DError
What happens if you try np.sqrt(-9)?
AReturns nan or warning
BReturns 3
CReturns -3
DReturns 0
Why might data scientists use np.sqrt()?
ATo remove missing values
BTo sort data
CTo convert data to strings
DTo calculate square roots for data transformation
Explain how np.sqrt() works with both single numbers and arrays.
Think about how it handles one number versus many numbers.
You got /3 concepts.
    Describe what happens when np.sqrt() is used on negative numbers and why.
    Consider the math behind square roots and negative inputs.
    You got /3 concepts.