A list is defined as [1, 2, 3]. The programmer uses the method .append([4, 5]). What will the resulting list look like after execution?
Correct Answer: B
The append() method adds its argument as a single element. Therefore, the list [4, 5] is added as one nested list, resulting in [1, 2, 3, [4, 5]].
Question 17
Consider the following Python code: What will be printed when the code above is executed? 40
Correct Answer: D
The last element of the original list is 50. The slice from index 1 up to (but not including) index 4 is [20, 30, 40]. After removing 30 and appending 60, the list contains one occurrence of 10, and integer division by 10 produces [1, 2, 4, 5, 6].