LearnFrenzy
Sign in Take a free test

Modules and Packages · Predict the Output · Question 6

Exploring a module with dir() Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

What is the output of the following Python program?

main.py
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links