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

4/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=[14,52,7]
>>>> b=a.copy()
>>> b is a

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]
 
names2[0] = 'Alice'
names3[1] = 'Bob'
 
sum = 0
for ls in (names1, names2, names3):
    if ls[0] == 'Alice':
        sum += 1
    if ls[1] == 'Bob':
        sum += 10
 
print sum

Select an option to see the answer and solution.

What is the list comprehension equivalent for: 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?
[ord(ch) for ch in 'abc']

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]]
[B[row][col]*A[row][col] for row in range(3) for col in range(3)]

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(1)?

Select an option to see the answer and solution.

What is the output when we execute list("hello")?

Select an option to see the answer and solution.

What is the output of print(k) in the following Python code snippet?
k = [print(i) for i in my_string if i not in "aeiou"]
print(k)

Select an option to see the answer and solution.

Write a list comprehension equivalent for the Python code shown below.
for i in range(1, 101):
	if int(i*0.5)==i*0.5:
		print(i)

Select an option to see the answer and solution.

Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)

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]]]
 
def ttt(m):
    v = m[0][0]
 
    for row in m:
        for element in row:
           if v < element: v = element
 
    return v
 
print(ttt(data[0]))

Select an option to see the answer and solution.

What will be the output of the following Python code?
word1="Apple"
word2="Apple"
list1=[1,2,3]
list2=[1,2,3]
print(word1 is word2)
print(list1 is list2)

Select an option to see the answer and solution.

Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?

Select an option to see the answer and solution.

What will be the output of the following Python code?
names1 = ['Amir', 'Bala', 'Chales']
 
if 'amir' in names1:
    print(1)
else:
    print(2)

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=165
b=sum(list(map(int,str(a))))
print(b)

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=[[]]*3
a[1].append(7)
print(a)

Select an option to see the answer and solution.

What will be the output of the following Python code?
def unpack(a,b,c,d):
    print(a+d)
x = [1,2,3,4]
unpack(*x)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print([if i%2==0: i; else: i+1; for i in range(4)])

Select an option to see the answer and solution.