Complete the code to calculate the exponential of each element in the array.
import numpy as np arr = np.array([1, 2, 3]) result = np.[1](arr) print(result)
The np.exp() function calculates the exponential (e^x) of each element in the array.
Complete the code to calculate the natural logarithm of each element in the array.
import numpy as np arr = np.array([1, np.e, np.e**2]) result = np.[1](arr) print(result)
The np.log() function calculates the natural logarithm (log base e) of each element in the array.
Fix the error in the code to correctly compute the exponential of the array elements.
import numpy as np arr = [1, 2, 3] result = np.[1](arr) print(result)
The input arr is a list, but np.exp() can handle lists by converting them internally. The function to compute exponential is exp.
Fill both blanks to create a dictionary with words as keys and their lengths as values, but only include words longer than 3 characters.
words = ['data', 'is', 'fun', 'and', 'easy'] lengths = {word: [1] for word in words if [2] print(lengths)
The dictionary comprehension uses len(word) to get the length, and the condition len(word) > 3 to filter words longer than 3 characters.
Fill all three blanks to create a dictionary with uppercase words as keys and their logarithm values as values, but only include words with length greater than 2.
import numpy as np words = ['hi', 'log', 'data', 'np'] result = { [1]: np.[2](len(word)) for word in words if len(word) [3] 2 } print(result)
np.exp instead of np.logThe dictionary keys are uppercase words using word.upper(). The values are the natural logarithm of the word length using np.log. The filter keeps words with length greater than 2.