Discussion :: Python MCQs
-
What is the output of the code shown below?import math[str(round(math.pi)) for i in range (1, 6)]
A.
['3', '3', '3', '3', '3', '3']
|
B.
['3.1', '3.14', '3.142', '3.1416', '3.14159', '3.141582']
|
C.
['3', '3', '3', '3', '3']
|
D.
['3.1', '3.14', '3.142', '3.1416', '3.14159']
|
Answer : Option C
Explanation :
The list comprehension shown above rounds off pi(3.141) and returns its value, that is 3. This is done 5 times. Hence the output is: ['3', '3', '3', '3', '3'].
Be The First To Comment