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

3/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?
l1=[2,4,6]
l2=[-2,-4,-6]
for i in zip(l1, l2):
	print(i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
def increment_items(L, increment):
    i = 0
    while i < len(L):
        L[i] = L[i] + increment
        i = i + 1
 
values = [1, 2, 3]
print(increment_items(values, 2))
print(values)

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]]
zip(A, B)

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=["Apple","Ball","Cobra"]

a.sort(key=len) print(a)

Select an option to see the answer and solution.

What will be the output of the following Python code?
veggies = ['carrot', 'broccoli', 'potato', 'asparagus']
veggies.insert(veggies.index('broccoli'), 'celery')
print(veggies)

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < list2

Select an option to see the answer and solution.

Which of the following Python statements will result in the output: 6?
A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]

Select an option to see the answer and solution.

What will be the output of the following Python code?
l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]]
[[row[i] for row in l] for i in range(3)]

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[row][1] for row in (0, 1, 2)]

Select an option to see the answer and solution.

What is the output of the following piece of code?
a=list((45,)*4)
print((45)*4)
print(a)

Select an option to see the answer and solution.

What will be the output of the following Python code?
l=[[1, 2, 3], [4, 5, 6]]
for i in range(len(l)):
	for j in range(len(l[i])):
		l[i][j]+=10
l

Select an option to see the answer and solution.

To shuffle the list(say list1) what function do we use?

Select an option to see the answer and solution.

What will be the output of the following Python code?
t=32.00
[round((x-32)*5/9) for x in t]

Select an option to see the answer and solution.

To which of the following the "in" operator can be used to check if an item is in it?

Select an option to see the answer and solution.

Read the information given below carefully and write a list comprehension such that the output is: ['e', 'o']
w="hello"
v=('a', 'e', 'i', 'o', 'u')

Select an option to see the answer and solution.

What will be the output of the following Python code?
import math
[str(round(math.pi)) for i in range (1, 6)]

Select an option to see the answer and solution.

What will be the output of the following Python code?
l=[1,2,3,4,5]
[x&1 for x in l]

Select an option to see the answer and solution.

What will be the output of the following Python code?
a = [1, 5, 7, 9, 9, 1]

b=a[0]
x= 0 for x in range(1, len(a)): if a[x] > b: b = a[x] b= x print(b)

Select an option to see the answer and solution.

What will be the output of the following Python code?
a="hello"
b=list((x.upper(),len(x)) for x in a)
print(b)

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 row in range(0, len(values)):
    for column in range(0, len(values[row])):
        if v < values[row][column]:
            v = values[row][column]
 
print(v)

Select an option to see the answer and solution.