QuestionQ64

VerifiedModules and Packages

What output is expected from the following code?

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

In Python 2, 01 evaluates to the integer 1. The names returned by dir(math) are strings, and sys.path contains string path entries, so both type checks evaluate to True. True and True prints True.

Community Discussion

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