Complete the code to transpose the 2D array using numpy.
import numpy as np arr = np.array([[1, 2], [3, 4]]) transposed = arr.[1]()
The transpose() method swaps the axes of the array, turning rows into columns.
Complete the code to transpose a 3D numpy array by swapping the first and second axes.
import numpy as np arr = np.random.rand(2, 3, 4) transposed = arr.transpose([1])
To swap the first and second axes, use transpose((1, 0, 2)).
Fix the error in the code to correctly transpose the 2D numpy array.
import numpy as np arr = np.array([[5, 6], [7, 8]]) transposed = arr.[1]
The transpose method must be called with parentheses () to execute it.
Fill both blanks to create a dictionary with words as keys and their lengths as values, but only for words longer than 3 characters.
words = ['data', 'is', 'fun', 'and', 'cool'] lengths = {word: [1] for word in words if len(word) [2] 3}
The dictionary comprehension uses len(word) for values and filters words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, only for words longer than 3 characters.
words = ['data', 'is', 'fun', 'and', 'cool'] result = [1]: [2] for w in words if len(w) [3] 3}}
The dictionary comprehension uses w.upper() as keys, len(w) as values, and filters words with length greater than 3 using >.