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

8/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= [1, 2, 3, 4, 5]
for i in range(1, 5):
    a[i-1] = a[i]
for i in range(0, 5): 
    print(a[i],end = " ")

Select an option to see the answer and solution.

Write a list comprehension for number and its cube for l=[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?
A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]
[A[i][len(A)-1-i] for i in range(len(A))]

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
my_string = "hello world"
k = [(i.upper(), len(i)) for i in my_string]
print(k)

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>m = [[x, x + 1, x + 2] for x in range(0, 3)]

Select an option to see the answer and solution.