0
0
NumPydata~15 mins

np.arange() for range arrays in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Create and Use Arrays with np.arange()
📖 Scenario: You are working with daily temperatures recorded over a week. You want to create arrays representing days and temperature ranges to analyze the data easily.
🎯 Goal: Build arrays using np.arange() to represent days and temperature ranges, then print the arrays to see the results.
📋 What You'll Learn
Use np.arange() to create arrays
Create arrays with specific start, stop, and step values
Print the arrays to display the data
💡 Why This Matters
🌍 Real World
Scientists and analysts often need to create sequences of numbers to represent time, measurements, or ranges for experiments and data analysis.
💼 Career
Knowing how to create arrays with <code>np.arange()</code> is essential for data scientists and analysts to prepare and manipulate data efficiently.
Progress0 / 4 steps
1
Create an array of days using np.arange()
Import the numpy library as np. Then create an array called days using np.arange() that starts at 1 and ends at 8 (not including 8) to represent days 1 to 7.
NumPy
Need a hint?

Use np.arange(start, stop) where stop is one more than the last day you want.

2
Create an array of temperatures from 20 to 30
Create an array called temps using np.arange() that starts at 20, ends at 31 (not including 31), with a step of 1 to represent temperatures from 20 to 30 degrees.
NumPy
Need a hint?

Remember to include the step value as the third argument in np.arange().

3
Create an array of temperatures with step 0.5
Create an array called temps_half using np.arange() that starts at 20, ends at 22 (not including 22), with a step of 0.5 to represent temperatures increasing by half degrees.
NumPy
Need a hint?

Use a decimal number for the step to get half-degree increments.

4
Print all three arrays
Print the arrays days, temps, and temps_half each on a separate line to see their values.
NumPy
Need a hint?

Use three separate print() statements, one for each array.