Complete the code to add two arrays element-wise.
import numpy as np arr1 = np.array([1, 2, 3]) arr2 = np.array([4, 5, 6]) result = arr1 [1] arr2 print(result)
Using the + operator adds two arrays element-wise in NumPy.
Complete the code to multiply two arrays element-wise.
import numpy as np arr1 = np.array([2, 4, 6]) arr2 = np.array([1, 3, 5]) result = arr1 [1] arr2 print(result)
The * operator multiplies arrays element-wise in NumPy.
Fix the error in the code to subtract two arrays element-wise.
import numpy as np arr1 = np.array([10, 20, 30]) arr2 = np.array([1, 2, 3]) result = arr1 [1] arr2 print(result)
The - operator subtracts arrays element-wise in NumPy.
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 = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3} print(lengths)
The dictionary comprehension uses len(word) to get the length 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 = ['apple', 'bat', 'carrot', 'dog'] result = { [1]: [2] for word in words if len(word) [3] 3 } print(result)
The dictionary comprehension uses word.upper() as keys, len(word) as values, and filters words longer than 3 with >.