Boolean Type with NumPy Arrays
📖 Scenario: You are working with a small dataset of temperatures recorded over a week. You want to find out which days were warmer than 20 degrees Celsius.
🎯 Goal: Create a NumPy array of temperatures, set a threshold temperature, create a Boolean array showing which days are warmer than the threshold, and print the Boolean array.
📋 What You'll Learn
Create a NumPy array called
temperatures with the exact values: 18, 22, 19, 24, 20, 21, 17Create a variable called
threshold and set it to 20Create a Boolean NumPy array called
warm_days that is True where temperatures is greater than thresholdPrint the
warm_days array💡 Why This Matters
🌍 Real World
Checking temperature data to find days warmer than a certain value is common in weather analysis and climate studies.
💼 Career
Data scientists often use Boolean arrays to filter data quickly and make decisions based on conditions.
Progress0 / 4 steps