Try to match the following Python expressions with their correct output. str(Fal
ID: 3891823 • Letter: T
Question
Try to match the following Python expressions with their correct output.
str(False)
[ Choose ] 'False' False True <class 'str'> <class 'bool'>
type(True)
[ Choose ] 'False' False True <class 'str'> <class 'bool'>
bool("False")
[ Choose ] 'False' False True <class 'str'> <class 'bool'>
type("False")
[ Choose ] 'False' False True <class 'str'> <class 'bool'>
bool(0)
[ Choose ] 'False' False True <class 'str'> <class 'bool'>
Explanation / Answer
str(False) -- 'False'
type(True) -- <class 'bool'>
bool("False") -- True
type("False") -- <class 'str'>
bool(0) -- False
Explanation:
str() converts any value to string type.
bool() gives True for any non zero length string
type() returns the type of value passed to it.