Question 6
Back to Exercise
What is the output of the following Python program?
import math
print([n for n in dir(math) if n.startswith("is")])
- A ['isclose', 'isfinite', 'isinf', 'isnan']
- B ['isclose', 'isfinite', 'isinf', 'isnan', 'isqrt'] Correct
- C ['isqrt', 'isnan', 'isinf', 'isfinite', 'isclose']
- D []
Correct Answer: Option B
dir() returns the names sorted alphabetically. isqrt (integer square root) also starts with "is".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!