Login using Social Account
     Continue with GoogleLogin using your credentials
Below are few more special NumPy arrays that you can create, having values within a particular given range.
For example, you can create a NumPy array in the below ways:
arange()
function of NumPy)linspace()
function of NumPy)Note: Please import numpy as np
(1) Creating a NumPy array by passing a range of values (using arange()
function of NumPy)
Suppose you want to create a NumPy array whose values should lie between 10 and 30 and the values should have a gap of the value of 5
To create this NumPy array, pass the start value (10), end value (30) and the gap value 5, to the arange()
function below
my_range_array = np.arange( <<your code comes here>>)
The above NumPy array my_range_array will be filled with values between 10 and 30 (excluding 30) having a gap of the value of 5 between the consecutive values.
(2) Creating a NumPy array by passing an equally spaced range of values (using linspace()
function of NumPy)
Suppose you want to create a NumPy array whose values should lie between 0 and 5/3 and the consecutive values should have an equal amount of gap between them (equally spaced values).
To create this NumPy array, pass the start value (0), end value (5/3), and the total number of values you want (say 6), to the linspace()
function below
my_spaced_array = np.linspace( <<your code comes here>>)
The above NumPy array my_spaced_array
will have total of 6 values with values ranging between 0 and 5/3 (including 5/3) and having an equal amount of gap between the consecutive values.
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...