Question 16 The following is an example of slice assignment.) Consider this prog
ID: 3905256 • Letter: Q
Question
Question 16 The following is an example of slice assignment.) Consider this program, where m is a positive even integer: Ls list (range(e,m)) 1ste:m//2] What statements about Is are then true? the second half of all its elements have been removed its new value is equal to expression list(range(m//2,m)) each element in the first half was replaced byD the first half of all its elements have been removed Question 17 Consider list object Ist initialized with [4, 1,2,5, 14,3],0]. Which of the following Python expressions is false ? O [4,3] in Ist Is Is:-1]I:-1] countl4)1 O [2, 5) in IstExplanation / Answer
16 Ans: its new value is equal to the expression :ls = list(range(m//2,m)) And the first half of the list is removed.
The statement: ls =list(range(0,m)) creates a list named lswith values from 0 to m-1, eg for m=6, ls=[0,1,2,3,4,5].
And the statement: ls[0:m//2] = [] slices the list ls from 0 to m/2 - 1 i.e., first half is sliced off. Left is [3,4,5]
Just like that the statement: ls = list(range(m//2,m)) , creates a list ls ranging from m/2 to m-1 i.e., [3,4,5].
17. [2,5] in lst is false. It checks if the element [2,5] which is a list in itself is present in lst. Since, it is not in lst, it returns false.