Vidyalelo
Python · all questions

Python Lists MCQs: Exam Practice for List Concepts
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

147

Questions

2/8

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following code:
my_list = [1, 2, 3]
my_list[1] = 4
print(my_list)

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3, 4, 5]
print(my_list[1:4])

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3, 4]
my_list.remove(2)
print(my_list)

Select an option to see the answer and solution.

What will the following code output:
my_list = [1, 2, 3]
new_list = my_list.copy()
print(new_list)

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3]
del my_list[1]
print(my_list)

Select an option to see the answer and solution.

Which method is used to sort the elements of a list in ascending order?

Select an option to see the answer and solution.

What is the purpose of the reverse() method for lists?

Select an option to see the answer and solution.

What will be the output of the following code:
my_list = [1, 2, 3]
my_list.reverse()
print(my_list)

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3, 4]
my_list.pop()
print(my_list)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = [i**+1 for i in range(3)]; print(x);

Select an option to see the answer and solution.

What will be the output of the following Python code?
print(list(zip((1,2,3),('a'),('xxx','yyy'))))
print(list(zip((2,4),('b','c'),('yy','xx'))))

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?

Select an option to see the answer and solution.

What will be the output of the following Python code?
l1=[10, 20, 30]
l2=[-10, -20, -30]
l3=[x+y for x, y in zip(l1, l2)]
print(l3)

Select an option to see the answer and solution.

Suppose list1 is [1, 3, 2], What is list1 * 2?

Select an option to see the answer and solution.

What will be the output of the following Python code?
def example(L):
    ''' (list) -> list
    '''
    i = 0
    result = []
    while i < len(L):
        result.append(L[i])
        i = i + 3
    return result

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=[1,2,3]
b=a.append(4)
print(a)
print(b)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print([i+j for i in "abc" for j in "def"])

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])

Select an option to see the answer and solution.

To add a new element to a list we use which command?

Select an option to see the answer and solution.