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

6/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?
names1 = ['Amir', 'Bala', 'Charlie']
names2 = [name.lower() for name in names1]
 
print(names2[2][0])

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?
l1=[1,2,3]
l2=[4,5,6]
[x*y for x in l1 for y in l2]

Select an option to see the answer and solution.

To remove string "hello" from list1, we use which command?

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.pop()?

Select an option to see the answer and solution.

Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?

Select an option to see the answer and solution.

What will be the output of the following Python code?
b=[2,3,4,5]
a=list(filter(lambda x:x%2,b))
print(a)

Select an option to see the answer and solution.

What will be the output of the following Python code?
points = [[1, 2], [3, 1.5], [0.5, 0.5]]
points.sort()
print(points)

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
s="a@b@c@d"
a=list(s.partition("@"))
print(a)
b=list(s.split("@",3))
print(b)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print([i.lower() for i in "HELLO"])

Select an option to see the answer and solution.

What will be the output of the following Python code?
matrix = [[1, 2, 3, 4],
       [4, 5, 6, 7],
       [8, 9, 10, 11],
       [12, 13, 14, 15]]
 
for i in range(0, 4):
    print(matrix[i][1], end = " ")

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[1]

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=[10,23,56,[78]]
b=list(a)
a[3][0]=95
a[1]=34
print(b)

Select an option to see the answer and solution.

What will be the output of the following Python code?
def addItem(listParam):
    listParam += [1]
 
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))

Select an option to see the answer and solution.

What will be the output of the following Python code?
x=[[1],[2]]
print(" ".join(list(map(str,x))))

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(a))]
print(b)

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]]
 
[[col + 10 for col in row] for row in A]

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(a))]
print(b)

Select an option to see the answer and solution.