0
0
NumPydata~10 mins

np.sqrt() for square roots in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Calculate Square Roots Using np.sqrt()
📖 Scenario: You work in a bakery that wants to analyze the sizes of square cake pans. You have a list of areas of square pans, and you want to find the length of one side of each pan.
🎯 Goal: Use np.sqrt() to calculate the side lengths from the given areas.
📋 What You'll Learn
Create a numpy array called areas with the exact values: 16, 25, 36, 49, 64
Create a variable called side_lengths that stores the square roots of the areas array using np.sqrt()
Print the side_lengths array
💡 Why This Matters
🌍 Real World
Calculating square roots is useful in many fields like baking, construction, and science when you need to find side lengths from areas.
💼 Career
Data scientists often use numpy functions like <code>np.sqrt()</code> to quickly perform mathematical operations on data arrays.
Progress0 / 4 steps
1
Create the numpy array of areas
Import numpy as np and create a numpy array called areas with these exact values: 16, 25, 36, 49, 64
NumPy
Need a hint?

Use np.array() to create the array with the given numbers.

2
Prepare to calculate square roots
Create a variable called side_lengths and set it to None for now as a placeholder
NumPy
Need a hint?

This step sets up the variable before calculation.

3
Calculate the square roots using np.sqrt()
Use np.sqrt() on the areas array and assign the result to the variable side_lengths
NumPy
Need a hint?

Call np.sqrt() with areas inside the parentheses.

4
Print the side lengths
Print the variable side_lengths to display the side lengths of the square pans
NumPy
Need a hint?

Use print(side_lengths) to show the results.