Select an option to see the answer and solution.
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
5/8
Page
Pick an option on a question to see the right answer and solution.
[j for i in range(2,8) for j in range(i*2, 50, i)]Select an option to see the answer and solution.
Select an option to see the answer and solution.
s=["pune", "mumbai", "delhi"]
[(w.upper(), len(w)) for w in s]Select an option to see the answer and solution.
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][i] for i in range(len(A))]Select an option to see the answer and solution.
Select an option to see the answer and solution.
lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print(lst)Select an option to see the answer and solution.
def f(i, values = []):
values.append(i)
return values
f(1)
f(2)
v = f(3)
print(v)Select an option to see the answer and solution.
myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
if myList[i] > max:
max = myList[i]
indexOfMax = i
>>>print(indexOfMax)Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
r = [11, 12, 13, 14, 15, 16, 17, 18, 19]
A = [[0, 10, 20],
[30, 40, 50],
[60, 70, 80]]
for row in A:
for col in row:
r.append(col+10)
rSelect an option to see the answer and solution.
places = ['Bangalore', 'Mumbai', 'Delhi']
places1 = places
places2 = places[:]
places1[1]="Pune"
places2[2]="Hyderabad"
print(places)Select an option to see the answer and solution.
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]]
for row in values:
row.sort()
for element in row:
print(element, end = " ")
print()Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
l1=[1,2,3]
l2=[4,5,6]
l3=[7,8,9]
for x, y, z in zip(l1, l2, l3):
print(x, y, z)Select an option to see the answer and solution.
def m(list):
v = list[0]
for e in list:
if v < e: v = e
return v
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
for row in values:
print(m(row), end = " ")Select an option to see the answer and solution.
Select an option to see the answer and solution.
Q100
Open questionlst=[[1,2],[3,4]]
print(sum(lst,[]))Select an option to see the answer and solution.