Finding Minimum and Maximum Indices with np.argmin() and np.argmax()
📖 Scenario: Imagine you have a list of daily temperatures for a week. You want to find which day was the coldest and which day was the hottest.
🎯 Goal: You will create a NumPy array of temperatures, set a threshold temperature, find the indices of the coldest and hottest days using np.argmin() and np.argmax(), and then print those indices.
📋 What You'll Learn
Create a NumPy array called
temperatures with exact values: [22, 19, 25, 21, 20, 23, 18]Create a variable called
threshold and set it to 20Use
np.argmin(temperatures) to find the index of the coldest day and store it in coldest_dayUse
np.argmax(temperatures) to find the index of the hottest day and store it in hottest_dayPrint the values of
coldest_day and hottest_day💡 Why This Matters
🌍 Real World
Finding minimum and maximum values and their positions is common in weather data analysis, stock prices, and many other fields.
💼 Career
Data scientists often need to quickly identify key points in data sets, such as the lowest or highest values, to make decisions or create reports.
Progress0 / 4 steps