Complete the code to round the values in the array to the nearest integer.
import numpy as np arr = np.array([1.2, 2.5, 3.7]) rounded = np.[1](arr) print(rounded)
The np.round() function rounds each element in the array to the nearest integer.
Complete the code to get the largest integer less than or equal to each element in the array.
import numpy as np arr = np.array([1.2, 2.5, 3.7]) floored = np.[1](arr) print(floored)
The np.floor() function returns the largest integer less than or equal to each element.
Fix the error in the code to get the smallest integer greater than or equal to each element.
import numpy as np arr = np.array([1.2, 2.5, 3.7]) ceiled = np.[1](arr) print(ceiled)
The np.ceil() function returns the smallest integer greater than or equal to each element.
Fill both blanks to create a dictionary with words as keys and their lengths rounded down if length is greater than 3.
import numpy as np words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: np.[1](len(word)) for word in words if len(word) [2] 3} print(lengths)
We use np.floor to round lengths down and filter words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths rounded up if length is less than 5.
import numpy as np words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word.[1](): np.[2](len(word)) for word in words if len(word) [3] 5} print(lengths)
We convert words to uppercase with upper(), round lengths up with ceil, and filter words with length less than 5 using <.