21
What will be the output of the following code:
my_list = [1, 2, 3]
my_list[1] = 4
print(my_list)
Answer & Solution
Answer: Option
B
22
What is the output of the following code:
my_list = [1, 2, 3, 4, 5]
print(my_list[1:4])
Answer & Solution
Answer: Option
A
23
What is the output of the following code:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
Answer & Solution
Answer: Option
C
24
What is the output of the following code:
my_list = [1, 2, 3, 4]
my_list.remove(2)
print(my_list)
Answer & Solution
Answer: Option
B
25
What will the following code output:
my_list = [1, 2, 3]
new_list = my_list.copy()
print(new_list)
Answer & Solution
Answer: Option
A
26
What is the output of the following code:
my_list = [1, 2, 3]
del my_list[1]
print(my_list)
Answer & Solution
Answer: Option
B
27
Which method is used to sort the elements of a list in ascending order?
Answer & Solution
Answer: Option
A
28
What is the purpose of the reverse() method for lists?
Answer & Solution
Answer: Option
A
29
What will be the output of the following code:
my_list = [1, 2, 3]
my_list.reverse()
print(my_list)
Answer & Solution
Answer: Option
B
30
What is the output of the following code:
my_list = [1, 2, 3, 4]
my_list.pop()
print(my_list)
Answer & Solution
Answer: Option
B