Complete the code to create a tuple named my_tuple with values 1, 2, and 3.
my_tuple = ([1])Tuples are created using parentheses with comma-separated values. So (1, 2, 3) creates a tuple.
Complete the code to access the second element of the tuple my_tuple.
second_element = my_tuple[[1]]Tuple elements start at index 0, so the second element is at index 1.
Fix the error in the code that tries to change the first element of the tuple my_tuple to 10.
my_tuple[[1]] = 10
Tuples are immutable, so you cannot assign a new value to any index. This code will cause an error no matter the index.
The fix is to create a new tuple instead of changing an element.
Fill both blanks to create a new tuple new_tuple by replacing the first element of my_tuple with 10.
new_tuple = ([1],) + my_tuple[[2]:]
We create a new tuple starting with 10, then add all elements of my_tuple from index 1 onward (skipping the first element at index 0).
Fill all three blanks to create a tuple filtered_tuple with only elements greater than 2 from my_tuple.
filtered_tuple = tuple(x for x in my_tuple if x [1] [2]) result = filtered_tuple[[3]]
This code filters elements greater than 2 and then gets the first element (index 0) of the filtered tuple.