List Interview Questions In Python: Python MCQs

List Interview Questions In Python. This section has Multiple Choice Questions on Lists in Python Language.

 

List Interview Questions In Python

 

 

Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3 ??

a) [x in range(1, 1000) if x%3==0]
b) [x for x in range(1000) if x%3==0]
c) [x%3 for x in range(1, 1000)]
d) [x%3=0 for x in range(1, 1000)]

 

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

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)
r

a) [11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 20, 30, 40, 50, 60, 70, 80, 90]
b) [10, 20, 30, 40, 50, 60, 70, 80, 90]
c) [11, 12, 13, 14, 15, 16, 17, 18, 19]
d) [0, 10, 20, 30, 40, 50, 60, 70, 80]

 

What will be the output ??

t=32.00
[round((x-32)*5/9) for x in t]

a) [0]
b) 0
c) [0.00]
d) Error

 

List Interview Questions In Python

 

What will be the output of the following Python ??

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[3, 3, 3],
[4, 4, 4],
[5, 5, 5]]
[B[row][col]*A[row][col] for row in range(3) for col in range(3)]

a) [3, 6, 9, 16, 20, 24, 35, 40, 45]
b) Error
c) [0, 30, 60, 120, 160, 200, 300, 350, 400]
d) 0

 

What is the output of the code ??

[ord(ch) for ch in ‘abc’]

a) [97, 98, 99]
b) [‘97’, ‘98’, ‘99’]
c) [65, 66, 67]
d) Error

 

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

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][len(A)-1-i] for i in range(len(A))]

a) [1, 5, 9]
b) [4, 5, 6]
c) [3, 5, 7]
d) [2, 5, 8]

 

List Interview Questions In Python

 

Write a list comprehension such that the output is: [‘e’, ‘o’] ??

w=”hello”
v=(‘a’, ‘e’, ‘i’, ‘o’, ‘u’)

a) [x for w in v if x in v]
b) [x for x in w if x in v]
c) [x for x in v if w in v]
d) [x for v in w for x in w]

 

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

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]

[[col + 10 for col in row] for row in A]

a) [[11, 12, 13], [14, 15, 16], [17, 18, 19]]
b) Error
c) [11, 12, 13], [14, 15, 16], [17, 18, 19]
d) [11, 12, 13, 14, 15, 16, 17, 18, 19]

 

What will be the output ??

l=[[1, 2, 3], [4, 5, 6]]
for i in range(len(l)):
for j in range(len(l[i])):
l[i][j]+=10
l

a) No output
b) Error
c) [[1, 2, 3], [4, 5, 6]]
d) [[11, 12, 13], [14, 15, 16]]

 

List Interview Questions In Python

 

What is the output of the following Python code ??

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][i] for i in range(len(A))]

a) [1, 5, 9]
b) [3, 5, 7]
c) [4, 5, 6]
d) [2, 5, 8]

 

What is the output of the following Python ??

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[row][1] for row in (0, 1, 2)]

a) [7, 8, 9]
b) [4, 5, 6]
c) [2, 5, 8]
d) [1, 4, 7]

 

Which of the following Python statements will result in the output: 6 ??

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]

a) A[2][3]
b) A[2][1]
c) A[1][2]
d) A[3][2]

 

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

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
A[1]

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

 

Which of the following matrices will throw an error in Python ??

a) A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]

b) B = [[3, 3, 3]
[4, 4, 4]
[5, 5, 5]]

c) C = [(1, 2, 4),
(5, 6, 7),
(8, 9, 10)]

d) D = [2, 3, 4,
3, 3, 3,
4, 5, 6]

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!