List Questions In Python: Python Programming MCQs

List Questions In Python. Multiple Choice Questions in Python on the topic of Lists. For all related Lists MCQs in Python Language see Python MCQs

List Questions In Python

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

a) 0
b) 4
c) 1
d) 2

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

a) [2, 33, 222, 14]
b) Error
c) 25
d) [25, 14, 222, 33, 2]

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

a) 0
b) 1
c) 4
d) 2

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

a) Error
b) None
c) 25
d) 2

List Questions In Python

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

a) list1.remove(“hello”)
b) list1.remove(hello)
c) list1.removeAll(“hello”)
d) list1.removeOne(“hello”)

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

a) print(list1[0])
b) print(list1[:2])
c) print(list1[:-2])
d) all of the mentioned

To insert 5 to the third position in list1, we use which command ??

a) list1.insert(3, 5)
b) list1.insert(2, 5)
d) list1.append(3, 5)

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

a) list1.shuffle()
b) shuffle(list1)
c) random.shuffle(list1)
d) random.shuffleList(list1)

List Questions In Python

To add a new element to a list we use which command ??

b) list1.append(5)

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

a) 1
b) 9
c) 15
d) Error

What will be the output of the following Python code ??

>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < list2 is

a) True
b) False
c) Error
d) None

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

a) 3
b) 5
c) 25
d) 1

List Questions In Python

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

a) [0, 1, 2, 3]
b) [0, 1, 2, 3, 4]
c) [0.0, 0.5, 1.0, 1.5]
d) [0.0, 0.5, 1.0, 1.5, 2.0]

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

a) 2445
b) 133
c) 12454
d) 123

Suppose list1 is [1, 3, 2], What is list1 * 2 ??

a) [2, 6, 4]
b) [1, 3, 2, 1, 3]
c) [1, 3, 2, 1, 3, 2]
d) [1, 3, 2, 3, 2, 1]

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

a) 5
b) 4
c) None
d) Error

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

a) 11
b) 12
c) 21
d) 22

error: Content is protected !!