QuestionQ125

VerifiedModules and Packages

What is the expected output from the following code?

import sys  
import math  
  
b1 = type(dir(math)[0]) is str  
b2 = type(sys.path[-1]) is str  
print(b1 and b2)  
Explanation

dir(math) produces attribute names as strings, and sys.path contains string search-path entries. Both type checks evaluate to True, so their logical and prints True.

Community Discussion

No comments yet. Be the first to start the discussion!