Import the NumPy library under the alias np
.
Given the following NumPy array, return the first element and the last element.
arr = np.array([8,2,4,9,7,3,8,1])
#Return the first element here
#Returns the last element here
Given the following NumPy array, return the entire array except for the last element.
new_arr = np.array([1,6,4,8,7,5,2,1,4,5,6,1,4,5,6,2,1])
#Place your solution here
Change the second element of this_arr
to 4
.
this_arr = np.array([2,4,89,7,5,4,2,6,4,5,78,1,6,9,7,456,12,45])
#Place your solution here
this_arr[1] = 4
Given the array original_array
, create a reference to that array called reference_array
. Change the second element of reference_array
to 16
and then print original_array
to verify that it modified the original data structure.
original_array = np.array([12,45,86,79,45,26,13,46,28])
#Solution goes here
Given the array first_array
, create a copy of the array called copy_array
. Change the third element of copy_array
to 42
and then print first_array
to verify that its elements remain unchanged.
first_array = np.array([16,45,75,16,43,45,78,19,23,46,79,58])
#Solution goes here
Given the two-dimensional array matrix
, print the value 35
.
matrix = np.array([[15, 120, 115],[230, 35, 130],[335, 420, 425]])
#Solution goes here
Given the array integer_array
, print a NumPy array of Boolean values that indicate whether the corresponding values in integer_array
are greater than 4.
integer_array = np.array([2,6,4,9,8,5,3,1,2,5,4,8,7,5,6])
#Solution goes here
Given the same array integer_array
, print a new NumPy array that only includes the values from integer_array
that are less then 6
.