Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer
Q. print(veggies)
a. [‘carrot’, ‘celery’, ‘broccoli’, ‘potato’, ‘asparagus’] correct 1.00
b. [‘carrot’, ‘celery’, ‘potato’, ‘asparagus’]
c. [‘carrot’, ‘broccoli’, ‘celery’, ‘potato’, ‘asparagus’]
d. [‘celery’, ‘carrot’, ‘broccoli’, ‘potato’, ‘asparagus’]
Q. >>>m = [[x, x + 1, x + 2] for x in range(0, 3)]
a. [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
b. [[0, 1, 2], [1, 2, 3], [2, 3, 4]]
c. [1, 2, 3, 4, 5, 6, 7, 8, 9]
d. [0, 1, 2, 1, 2, 3, 2, 3, 4]
Q. 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]]
Q. for i in range(3)]; print(x);
a. [0, 1, 2]
b. [1, 2, 5]
c. error, **+ is not a valid operator
d. error, ‘;’ is not allowed
Q. ==0: i; else: i+1; for i in range(4)])
a. [0, 2, 2, 4]
b. [1, 1, 3, 3]
c. error
d. none of the mentioned
Q. Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))?
a. [x**-1 for x in [(1, 2, 3)]]
b. [1/x for x in [(1, 2, 3)]]
c. [1/x for x in (1, 2, 3)]
d. error
Q. for y in l2]
a. [4, 8, 12, 5, 10, 15, 6, 12, 18]
b. [4, 10, 18]
c. [4, 5, 6, 8, 10, 12, 12, 15, 18]
d. [18, 12, 6, 15, 10, 5, 12, 8, 4]
Q. Write the list comprehension to pick out only negative integers from a given list ‘l’.
a. [x<0 in l]
b. [x for x<0 in l]
c. [x in l for x<0]
d. [x for x in l if x<0]