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

7/8

Page

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

What will be the output of the following Python code?
a=[13,56,17]
a.append([87])
a.extend([45,67])
print(a)

Select an option to see the answer and solution.

What will be the output of the following Python code?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
 
print(data[1][0][0])

Select an option to see the answer and solution.

What will be the output of the following Python code?
numbers = [1, 2, 3, 4]
 
numbers.append([5,6,7,8])
 
print(len(numbers))

Select an option to see the answer and solution.

Write a list comprehension to produce the list: [1, 2, 4, 8, 16......212].

Select an option to see the answer and solution.

Which of the following matrices will throw an error in Python?

Select an option to see the answer and solution.

Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5])?

Select an option to see the answer and solution.

What will be the output of the following Python code?
A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]
B = [[3, 3, 3],
     [4, 4, 4],
     [5, 5, 5]]
[[col1 * col2 for (col1, col2) in zip(row1, row2)] for (row1, row2) in zip(A, B)]

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>"Welcome to Python".split()

Select an option to see the answer and solution.

What will be the output of the following Python code?
num = ['One', 'Two', 'Three']
for i, x in enumerate(num):
    print('{}: {}'.format(i, x),end=" ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>list("a#b#c#d".split('#'))

Select an option to see the answer and solution.

What will be the output of the following Python code?
def change(var, lst):
    var = 1
    lst[0] = 44
k = 3
a = [1, 2, 3]
change(k, a)
print(k)
print(a)

Select an option to see the answer and solution.

Which of the following commands will create a list?

Select an option to see the answer and solution.

What is the list comprehension equivalent for?
{x : x is a whole number less than 20, x is even}    (including zero)

Select an option to see the answer and solution.

What will be the output of the following Python code?
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
 
v = values[0][0]
for lst in values:
    for element in lst:
        if v > element:
            v = element
 
print(v)

Select an option to see the answer and solution.

What will be the output of the following Python code?
l=["good", "oh!", "excellent!", "#450"]
[n for n in l if n.isalpha() or n.isdigit()]

Select an option to see the answer and solution.

Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))?

Select an option to see the answer and solution.

What will be the output of the following Python code?
myList = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
    myList[i - 1] = myList[i]
 
for i in range(0, 6): 
    print(myList[i], end = " ")

Select an option to see the answer and solution.

Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?

Select an option to see the answer and solution.

How many elements are in m?
m = [[x, y] for x in range(0, 4) for y in range(0, 4)]

Select an option to see the answer and solution.

Write the list comprehension to pick out only negative integers from a given list 'l'.

Select an option to see the answer and solution.