0
0
NumPydata~30 mins

Why math functions matter in NumPy - See It in Action

Choose your learning style9 modes available
Why math functions matter
📖 Scenario: Imagine you are a data analyst working with a small set of numbers representing daily temperatures in Celsius. You want to understand these numbers better by using math functions to find their square roots, squares, and absolute values. This helps you see the data in new ways and prepare it for further analysis.
🎯 Goal: You will create a list of temperatures, set up a configuration variable for a threshold, apply math functions from the numpy library to transform the data, and finally print the results.
📋 What You'll Learn
Create a list of temperatures with exact values
Create a threshold variable to compare values
Use numpy math functions: square root, square, and absolute value
Print the transformed data
💡 Why This Matters
🌍 Real World
Math functions help data scientists transform and understand data better. For example, square roots can normalize data, squares can emphasize larger values, and absolute values remove negative signs to focus on magnitude.
💼 Career
Knowing how to use math functions with numpy is essential for data cleaning, feature engineering, and preparing data for machine learning models.
Progress0 / 4 steps
1
Create the temperature data list
Create a list called temperatures with these exact values: 16, -9, 25, -4, 0.
NumPy
Need a hint?

Use square brackets to create a list and separate numbers with commas.

2
Set a threshold value
Create a variable called threshold and set it to 10.
NumPy
Need a hint?

Just assign the number 10 to the variable named threshold.

3
Apply numpy math functions
Import numpy as np. Then create three new lists: sqrt_temps with the square roots of the absolute values of temperatures, square_temps with the squares of temperatures, and abs_temps with the absolute values of temperatures.
NumPy
Need a hint?

Use np.abs() to get absolute values, np.sqrt() for square roots, and np.square() for squares. Convert results to lists.

4
Print the transformed temperature lists
Print the lists sqrt_temps, square_temps, and abs_temps each on a separate line.
NumPy
Need a hint?

Use three separate print statements, one for each list.