Complete the code to multiply each element in the array by 3.
import numpy as np arr = np.array([1, 2, 3, 4]) result = arr [1] 3 print(result)
Using the * operator multiplies each element of the array by the scalar value.
Complete the code to subtract 5 from each element in the array.
import numpy as np arr = np.array([10, 15, 20, 25]) result = arr [1] 5 print(result)
The - operator subtracts the scalar from each element in the array.
Fix the error in the code to divide each element by 2 correctly.
import numpy as np arr = np.array([8, 16, 24, 32]) result = arr [1] 2 print(result)
The / operator divides each element of the array by the scalar.
Fill both blanks to create a dictionary with words as keys and their lengths squared if length is greater than 3.
words = ['data', 'science', 'ai', 'ml'] lengths = {word: len(word)[1] 2 for word in words if len(word) [2] 3} print(lengths)
The ** operator squares the length, and > checks if length is greater than 3.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths if length is less than 5.
words = ['data', 'science', 'ai', 'ml'] result = {word[1]: [2] for word in words if len(word) [3] 5} print(result)
.upper() converts words to uppercase keys, len(word) gets length, and < filters words shorter than 5.