Suppose list1 is (3, 4, 5, 20, 5, 25, 1, 3), what is len(list1)

Python List Programming Questions

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

Show Answer

b] 5

Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop[] ??

a] [3, 4, 5, 20, 5, 25, 1]
b] [1, 3, 3, 4, 5, 5, 20, 25]
c] [3, 5, 20, 5, 25, 1, 3]
d] [1, 3, 4, 5, 20, 5, 25]

Show Answer

a] [3, 4, 5, 20, 5, 25, 1]

What will be the output of the following code ??

names1 = [‘Amir’, ‘Bala’, ‘Charlie’]
names2 = [name.lower[] for name in names1]
print[names2[2][0]]

a] None
b] a
c] b
d] c

Show Answer

d] c

Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop[1] ??

a] [3, 4, 5, 20, 5, 25, 1, 3]
b] [1, 3, 3, 4, 5, 5, 20, 25]
c] [3, 5, 20, 5, 25, 1, 3]
d] [1, 3, 4, 5, 20, 5, 25]

Show Answer

c] [3, 5, 20, 5, 25, 1, 3]

Python List Programming Questions

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

names1 = [‘Amir’, ‘Bala’, ‘Chales’]
if ‘amir’ in names1:
print[1]

else:
print[2]

a] None
b] 1
c] 2
d] Error

Show Answer

c] 2

Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend[[34, 5]] ??

a] [3, 4, 5, 20, 5, 25, 1, 3, 34, 5]
b] [1, 3, 3, 4, 5, 5, 20, 25, 34, 5]
c] [25, 20, 5, 5, 4, 3, 3, 1, 34, 5]
d] [1, 3, 4, 5, 20, 5, 25, 3, 34, 5]

Show Answer

a] [3, 4, 5, 20, 5, 25, 1, 3, 34, 5]

What is the output of the following Python code ??

def f[i, values = []]:
values.append[i]
return values

f[1]
f[2]
v = f[3]
print[v]

a] [1] [2] [3]
b] [1] [1, 2] [1, 2, 3]
c] [1, 2, 3]
d] 1 2 3

Show Answer

c] [1, 2, 3]

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

a] [3, 4, 5, 20, 5, 25, 1, 3]
b] [1, 3, 3, 4, 5, 5, 20, 25]
c] [25, 20, 5, 5, 4, 3, 3, 1]
d] [3, 1, 25, 5, 20, 5, 4, 3]

Show Answer

d] [3, 1, 25, 5, 20, 5, 4, 3]

Python List Programming Questions

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

lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print[lst]

a] [3, 7, 8, 6, 1, 2]
b] Syntax error
c] [3,[7,8],6,1,2]
d] [3,4,6,7,8]

Show Answer

a] [3, 7, 8, 6, 1, 2]

What will be the output of the following code ??

points = [[1, 2], [3, 1.5], [0.5, 0.5]]
points.sort[]
print[points]

a] [[1, 2], [3, 1.5], [0.5, 0.5]]
b] [[3, 1.5], [1, 2], [0.5, 0.5]]
c] [[0.5, 0.5], [1, 2], [3, 1.5]]
d] [[0.5, 0.5], [3, 1.5], [1, 2]]

Show Answer
c] [[0.5, 0.5], [1, 2], [3, 1.5]]

What will be the output of the following ??

b=[2,3,4,5]
a=list[filter[lambda x:x%2,b]]
print[a]

a] [2,4]
b] [ ]
c] [3,5]
d] Invalid arguments for filter function

Show Answer

c] [3,5]

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]]]

a] 1
b] 2
c] 4
d] 5

Show Answer

c] 4

Python List Programming Questions

What will be the output of the code ??

a=[[]]*3
a[1].append[7]
print[a]

a] Syntax error
b] [[7], [7], [7]]
c] [[7], [], []]
d] [[],7, [], []]

Show Answer

b] [[7], [7], [7]]

What will be the output of the following code ??

data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
print[data[1][0][0]]

a] 1
b] 2
c] 4
d] 5

Show Answer

d] 5

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

a=[1,2,3,4]
b=[sum[a[0:x+1]] for x in range[0,len[a]]]
print[b]

a] 10
b] [1,3,5,7]
c] 4
d] [1,3,6,10]

Show Answer

d] [1,3,6,10]

Video liên quan

Bài mới nhất

Chủ Đề