adplus-dvertising

Welcome to the Lists in Python MCQs Page

Dive deep into the fascinating world of Lists in Python with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Lists in Python, a crucial aspect of Python. In this section, you will encounter a diverse range of MCQs that cover various aspects of Lists in Python, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Python.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Lists in Python. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Python.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Lists in Python. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Lists in Python MCQs | Page 3 of 12

Q21.
What is the output when following code is executed ?
myList = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
    myList[i - 1] = myList[i]
 
for i in range(0, 6): 
    print(myList[i], end = " ")
Discuss
Answer: (c).2 3 4 5 6 6
Q22.
What is the output when following code is executed ?
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)
Discuss
Answer: (b).[4, 3].
Q23.
What is the output when following code is executed ?
def f(values):
    values[0] = 44
 
v = [1, 2, 3]
f(v)
print(v)
Discuss
Answer: (c).[44, 2, 3].
Q24.
What will be the output?
def f(i, values = []):
    values.append(i)
    return values
 
f(1)
f(2)
v = f(3)
print(v)
Discuss
Answer: (c).[1, 2, 3].
Q25.
What will be the output?
names1 = ['Amir', 'Bala', 'Chales']
 
if 'amir' in names1:
    print(1)
else:
    print(2)
Discuss
Answer: (c).2
Q26.
What will be the output?
names1 = ['Amir', 'Bala', 'Charlie']
names2 = [name.lower() for name in names1]
 
print(names2[2][0])
Discuss
Answer: (d).c
Q27.
What will be the output?
numbers = [1, 2, 3, 4]
 
numbers.append([5,6,7,8])
 
print(len(numbers))

a.

4

b.

5

c.

8

d.

12

Discuss
Answer: (b).5
Q28.
To which of the following the “in” operator can be used to check if an item is in it?
Discuss
Answer: (d).All of the mentioned
Q29.
What will be the output?
list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]
 
print(len(list1 + list2))

a.

2

b.

4

c.

5

d.

8

Discuss
Answer: (d).8
Q30.
What will be the output?
def addItem(listParam):
    listParam += [1]
 
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))

a.

1

b.

4

c.

5

d.

8

Discuss
Answer: (c).5
Page 3 of 12

Suggested Topics

Are you eager to expand your knowledge beyond Python? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!