Recall & Review
beginner
What does the function
np.eye(n) do in NumPy?It creates an identity matrix of size
n x n. This matrix has 1s on the diagonal and 0s elsewhere.Click to reveal answer
beginner
How can you create a 4x4 identity matrix using
np.eye()?Use
np.eye(4). This returns a 4 by 4 matrix with 1s on the diagonal and 0s elsewhere.Click to reveal answer
intermediate
What is the difference between
np.eye(n) and np.identity(n)?np.eye(n) can create rectangular matrices by specifying rows and columns, while np.identity(n) only creates square identity matrices of size n x n.Click to reveal answer
intermediate
How do you create a 3x5 matrix with 1s on the diagonal using
np.eye()?Use
np.eye(3, 5). This creates a matrix with 3 rows and 5 columns, with 1s on the diagonal and 0s elsewhere.Click to reveal answer
intermediate
What parameter in
np.eye() controls the diagonal offset?The
k parameter controls which diagonal to place the 1s on. k=0 is the main diagonal, k>0 is above, and k<0 is below the main diagonal.Click to reveal answer
What does
np.eye(3) produce?✗ Incorrect
np.eye(3) creates a 3x3 identity matrix with 1s on the diagonal and 0s elsewhere.How do you create a 2x4 matrix with 1s on the diagonal using
np.eye()?✗ Incorrect
np.eye(2, 4) creates a matrix with 2 rows and 4 columns with 1s on the diagonal.What does the parameter
k in np.eye(n, m, k) do?✗ Incorrect
The
k parameter shifts the diagonal where 1s appear: 0 is main diagonal, positive is above, negative is below.Which function only creates square identity matrices?
✗ Incorrect
np.identity() creates only square identity matrices, while np.eye() can create rectangular ones.What will
np.eye(3, 3, k=1) produce?✗ Incorrect
Setting
k=1 places 1s on the diagonal just above the main diagonal.Explain how to create an identity matrix and how to adjust its size and shape using
np.eye().Think about rows, columns, and diagonal offset.
You got /4 concepts.
Describe the difference between
np.eye() and np.identity().Focus on shape flexibility.
You got /3 concepts.