Using np.abs() to Find Absolute Values
📖 Scenario: Imagine you have a list of temperature changes recorded over a week. Some values are negative, showing a drop in temperature, and some are positive, showing a rise. You want to find out how big the changes were, regardless of direction.
🎯 Goal: You will create a NumPy array with temperature changes, then use np.abs() to find the absolute values of these changes. This will help you see the size of each change without worrying about whether it was up or down.
📋 What You'll Learn
Create a NumPy array called
temp_changes with the exact values: -3, 5, -1, 7, -4Create a variable called
absolute_changes that stores the absolute values of temp_changes using np.abs()Print the
absolute_changes array💡 Why This Matters
🌍 Real World
Absolute values are useful in many real-world cases like measuring distances, temperature changes, or financial gains and losses without worrying about direction.
💼 Career
Data scientists often use absolute values to analyze data magnitude, ignoring whether values are positive or negative, which helps in clearer insights and decision making.
Progress0 / 4 steps