Quiz (MCQ) for practice

A few Python mcq to practice.

1) What will be the output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x)))))

a) (‘[0] [1]’,)
b) (’01’,)
c) [0] [1]
d) 01


2) Suppose list1 is [1, 3, 2], What is list1 * 2?

a) [1,3,2,1,3,2]
b) [2,6,4]
c) [1,9,4]
d) error occurs


3)  What will be the output of the following Python code?
try:
  if '1' != 1:
    raise "someError"
  else:
    print("someError has not occurred")
except "someError":
  print ("someError has occurred")

a) someError has occurred
b) someError has not occurred
c) invalid code
d) none of the mentioned


4)  Consider the following list as input:
numbers = [1, 2, 3]
Which of the following would produce the result: [2]

a) list(filter(lambda x: (x + 1) * 3 / 3 % 3 == 0, numbers))
b) list(filter(lambda x: 2, numbers))
c) list(filter(lambda x: x == 0, numbers))
d) list(filter(lambda x: x > 1, numbers))

2 Likes

qs 1

c) [0] [1]

qs 2

[1,3,2,1,3,2]

qs 3

c) invalid code

qs 4

c) list(filter(lambda x: x == 0, numbers))

Answers are C A C A

@prabhudevaraj11
nice :+1: keep it up

answers for above are:
----> c,a,a,a