Complete the code to select the last element of the numpy array.
import numpy as np arr = np.array([10, 20, 30, 40, 50]) last_element = arr[1]
Using arr[-1] selects the last element in the array.
Complete the code to select the second last element of the numpy array.
import numpy as np arr = np.array([5, 15, 25, 35, 45]) second_last = arr[1]
arr[-2] selects the second last element in the array.
Fix the error in the code to correctly select the last three elements using negative indexing.
import numpy as np arr = np.array([2, 4, 6, 8, 10, 12]) last_three = arr[1]
arr[-3:] selects the last three elements of the array.
Fill both blanks to create a dictionary with words as keys and their last two characters as values.
words = ['apple', 'banana', 'cherry'] last_two_chars = {word: word[1] for word in words if len(word) [2] 2}
The slice word[-2:] gets the last two characters. The condition len(word) > 2 ensures words are long enough.
Fill all three blanks to create a dictionary with uppercase words as keys and their last character as values, only for words longer than 3 letters.
words = ['dog', 'elephant', 'cat', 'giraffe'] result = {word[1]: word[2] for word in words if len(word) [3] 3}
word.upper() converts to uppercase keys, word[-1] gets last character, and len(word) > 3 filters words longer than 3 letters.