Chapter 7: Array-Oriented Programming with Num 3
c. You can iterate through a multidimensional array as if it were one-dimensional
by using its flat attribute.
d. All of the above statements are true.
7.4 Filling arrays with Specific Values
7.4 Q1: Which of the following statements a), b) or c) is false?
a. NumPy provides functions zeros, ones and full for creating arrays contain–
ing 0s, 1s or a specified value, respectively.
b. The first argument to the functions in Part (a) must be an integer or a tuple of
integers specifying the desired dimensions. For an integer, each function returns
a one-dimensional array with the specified number of elements. For a tuple of
integers, these functions return a multidimensional array with the specified di-
mensions.
c. The array returned by NumPy function full contains elements with the sec-
ond argument’s value and type.
d. All of the above statements are true.
7.5 Creating arrays from Ranges
7.5 Q1: Which of the following statements about NumPy’s linspace function is
false?
a. You can produce evenly spaced floating-point ranges with linspace.
b. The function’s first two arguments specify the starting and ending values in the
range, and the ending value is included in the array.
c. The optional keyword argument num specifies the number of evenly spaced val-
ues to produce—this argument’s default value is 50.
d. All of the above statements are true.
7.5 Q2: Which of the following statements a), b) or c) is false?
a. You can create an array from a range of elements, then use array method re-
shape to transform the one-dimensional array into a multidimensional array.
b. The following code creates an array containing the values from 1 through 20,
then reshapes it into four rows by five columns:
import numpy as np
np.arange(1, 21).reshape(4, 5)