Unit 7: Operations on NumPy arrays - Subjective Questions

ECAP776 • Practice Questions with Detailed Answers

20 questions

1

Define array manipulation in NumPy. Explain any four commonly used array-manipulation operations with examples.

2

Explain the NumPy reshape() operation. What condition must be satisfied when an array is reshaped?

3

Distinguish between NumPy's flatten() and ravel() methods.

4

Describe transposition and axis permutation in NumPy. Compare arr.T, np.transpose(), and np.swapaxes().

5

Explain how arrays are joined using np.concatenate(), np.stack(), np.vstack(), and np.hstack().

6

Describe array splitting in NumPy using np.split(), np.array_split(), np.hsplit(), and np.vsplit().

7

What is broadcasting in NumPy? State and explain its compatibility rules.

8

Derive the broadcasted output shape for arrays with shapes and . Explain the comparison axis by axis.

9

Explain row-wise and column-wise broadcasting for a matrix of shape . Give one compatible vector shape for each case.

10

Describe how np.newaxis and np.expand_dims() help control broadcasting.

11

Compare implicit broadcasting with np.broadcast_to() and np.tile().

12

Explain the advantages and possible limitations of broadcasting in numerical programs.

13

Explain NumPy's arithmetic binary operators and describe how they behave when applied to arrays.

14

Distinguish between element-wise multiplication, matrix multiplication, and the dot product in NumPy.

15

Describe comparison operators and boolean masks in NumPy. How can they be used to filter or modify an array?

16

Why should and, or, and not generally not be used to combine NumPy boolean arrays? Explain the correct alternatives and operator-precedence requirement.

17

Explain bitwise binary operators in NumPy and distinguish them from logical operations.

18

What are in-place binary operations in NumPy? Discuss their benefits and the data-type issue that may occur.

19

Explain NumPy universal functions and show how binary operators relate to binary ufuncs. Discuss the out and where parameters.

20

Given an array of shape , determine whether operands with shapes , , , and can be broadcast with it. Justify each answer.