Explore topic-wise MCQs in Python.

This section includes 7 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of print(k) in the following Python code snippet?

A. all characters of my_string that aren’t vowels
B. a list of Nones
C. list of Trues
D. list of FalsesView Answer
Answer» C. list of Trues
2.

WHAT_IS_THE_LIST_COMPREHENSION_EQUIVALENT_FOR:_LIST(MAP(LAMBDA_X:X**-1,_[1,_2,_3]))?$

A. [1|x for x in [1, 2, 3]]
B. [-1**x for x in [1, 2, 3]]
C. [x**-1 for x in [1, 2, 3]]
D. [x^-1 for x in range(4)]
Answer» C. [x**-1 for x in [1, 2, 3]]
3.

5)==(i*0.5)?

A. [i for i in range(1, 101) if int(i*0.5)==(i*0.5)]
B. [i for i in range(1, 101) if int(i*0.5)=(i*0.5)]
C. [i for i in range(1, 100) if int(i*0.5)=(i*0.5)]
Answer» D.
4.

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)]
Answer» B. [x for x in range(1000) if x%3==0]
5.

[0]

A. 0
B. [0.00]
C. Error
Answer» D.
6.

[97, 98, 99]

A. [‘97’, ‘98’, ‘99’]
B. [65, 66, 67]
C. Error
Answer» C. Error
7.

[x for w in v if x in v]

A. [x for x in w if x in v]
B. [x for x in v if w in v]
C. [x for v in w for x in w]
Answer» B. [x for x in v if w in v]