Check your understanding of the previous reading: indexing, comparing, testing membership, and adding to a list.
What is the value stored in my_var after the following strange code is executed?
my_var = [1, 2, 3][1]
Select one answer, then check.
[1] indexes into the list literal; the result is a single element, not the whole list.0 would be 1, but this code indexes at 1.[1, 2, 3] creates the list, and [1] right after it indexes at position 1, the second element: 2.print([2][0]) example.What is the value stored in my_var after the following code is executed?
my_var = [1, 2, 3] < 5
Select one answer, then check.
<, so this line never produces a boolean.<, so this line never produces a boolean.< raises a TypeError; Python cannot decide which is "less" between a list and a number.What is the value stored in my_var after the following code is executed?
my_var = 5 in [1, 3, 5]
Select one answer, then check.
5 is an exact element of [1, 3, 5], so the membership test succeeds.5 is in the list [1, 3, 5], so in returns True.What is the value stored in my_var after the following code is executed?
my_var = [1, 2, 3] + 4
Select one answer, then check.
+ - you need the append method for that.+ 4 is not silently ignored; it causes an error instead.+ with a plain number; + on a list expects another list, so this raises a TypeError.Which of the following demonstrates how to add something to the following list variable?
temperatures = [44, 36, 72]
Select one answer, then check.
append is a method on the list itself, not a standalone function you call with the list as an argument.append is called as a method on the list, adding 42 to the end of temperatures in place.+ does not work between a list and a number.42; nothing is added to it.