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

5/8

Page

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

Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?

Select an option to see the answer and solution.

What will be the output of the following Python list comprehension?
[j for i in range(2,8) for j in range(i*2, 50, i)]

Select an option to see the answer and solution.

Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.

Select an option to see the answer and solution.

What will be the output of the following Python code?
s=["pune", "mumbai", "delhi"]
[(w.upper(), len(w)) for w in s]

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]]
[A[i][i] for i in range(len(A))]

Select an option to see the answer and solution.

Suppose list1 is [1, 5, 9], what is sum(list1)?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
def f(i, values = []):
    values.append(i)
    return values
 
f(1)
f(2)
v = f(3)
print(v)

Select an option to see the answer and solution.

What will be the output of the following Python code?
myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
    if myList[i] > max:
        max = myList[i]
        indexOfMax = i
 
>>>print(indexOfMax)

Select an option to see the answer and solution.

Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?

Select an option to see the answer and solution.

Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)]?

Select an option to see the answer and solution.

What will be the output of the following Python code?
r = [11, 12, 13, 14, 15, 16, 17, 18, 19]
A = [[0, 10, 20],
               [30, 40, 50],
               [60, 70, 80]]
for row in A:
	for col in row:
		r.append(col+10)
r

Select an option to see the answer and solution.

What will be the output of the following Python code?
places = ['Bangalore', 'Mumbai', 'Delhi']

places1 = places places2 = places[:]
places1[1]="Pune" places2[2]="Hyderabad" print(places)

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]]
 
for row in values:
    row.sort()
    for element in row:
        print(element, end = " ")
    print()

Select an option to see the answer and solution.

Suppose listExample is ['h','e','l','l','o'], what is len(listExample)?

Select an option to see the answer and solution.

Suppose list1 is [2445,133,12454,123], what is max(list1)?

Select an option to see the answer and solution.

What will be the output of the following Python code?
l1=[1,2,3]
l2=[4,5,6]
l3=[7,8,9]
for x, y, z in zip(l1, l2, l3):
	print(x, y, z)

Select an option to see the answer and solution.

What will be the output of the following Python code?
def m(list):
    v = list[0]
    for e in list:
      if v < e: v = e
    return v
 
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
 
for row in values: 
    print(m(row), 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.

What will be the output of the following Python code?
lst=[[1,2],[3,4]]
print(sum(lst,[]))

Select an option to see the answer and solution.