Question: All these questions relate to Python. 1 . Which of the following code segments will use vectorisation to reduce the time taken to calculate the

All these questions relate to Python.
1. Which of the following code segments will use vectorisation to reduce the time taken to calculate the sum of two NumPy arrays: A and B?(Select ALL that apply)
a. A.tolist()+B.tolist()
b. A + B
c. np.add(A, B)
d. C = np.empty(A.size)
for index in range(A.size):
C[index]= A[index]+ B[index]
2. If two arrays of different dimensions are multiplied together, what is the result?
a. NumPy will return an error.
b. The result will have the shape to fit the largest array dimensions and fill missing values with NaN.
c. NumPy will treat the missing values as 1(copying the values of the larger arrays).
d. The result will have the shape to fit the smallest array dimensions and fill missing values with NaN.
3. Which of the hsplit() calls shown will result in the arrays A, B and C having the values shown in the picture?
Original array: O.
5.2|3.4|6.1|2.1|5.4
3.3|3.8|2.5|3.6|5.0
A.
5.2
3.3
B.
5.4
5.0
C.
3.4|6.1|2.1
3.8|2.5|3.6
a. A,B,C= np.hsplit(O,[1,4])
b. A,C,B = np.hsplit(O,[1,4])
c. A,B,C= np.hsplit(O[1,1,3])
d. A,C,B= np.hsplit(O[4,1])
4. The line np.random.random(15) will produce which of the following?
a. A one-dimensional array of NaNs
b. A one-dimensional array of 15 values between 0 and 1
c. A one-dimensional array of integers between 0 and 15
d. A one-dimensional array of 15 zero values
5. Objects can be changed or accessed through their property attributes or through their methods. For each of the following manipulations of NumPy arrays, identify if you can achieve the goal through the NumPy array property attribute, method or both.
To answer: select "property", "method" or "both" from below.
a. Access shape
- Both
- Method
- Property
b. Change shape
- Both
- Method
- Property
c. Sum values
- Both
- Method
- Property
d. Find minimum value
- Both
- Method
- Property

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!