Computer Science
Given a list L1 = [3, 4.5, 12, 25.7, [2, 1, 0, 5], 88], which function can change the list to:
- [3, 4.5, 12, 25.7, 88]
- [3, 4.5, 12, 25.7]
- [ [2, 1, 0, 5], 88]
Python List Manipulation
21 Likes
Answer
- L1.pop(4)
- del L1[4:6]
- del L1[:4]
Answered By
12 Likes
Related Questions
Given two lists:
L1 = ["this", 'is', 'a', 'List'], L2 = ["this", ["is", "another"], "List"]
Which of the following expressions will not result in error? Give output of expressions that do not result in error.
- L1 == L2
- L1.upper( )
- L1[3].upper( )
- L2.upper( )
- L2[1].upper( )
- L2[1][1].upper( )
Given a list L1 = [3, 4.5, 12, 25.7, [2, 1, 0, 5], 88]
- Which list slice will return [12, 25.7, [2, 1, 0, 5]]?
- Which expression will return [2, 1, 0, 5]?
- Which list slice will return [[2, 1, 0, 5]]?
- Which list slice will return [4.5, 25.7, 88]?
What will the following code result in?
L1 = [1, 3, 5, 7, 9] print (L1 == L1.reverse( ) ) print (L1)
Predict the output:
my_list= [ 'p', 'r', 'o', 'b', 'l' , 'e', 'm'] my_list[2:3] = [] print(my_list) my_list[2:5] = [] print(my_list)