Q. What is the result produced by

(i) bool (0)

(ii) bool (str(0)) ? Justify the outcome.

 

Answer =

(i) False: Integer value 0 has false truth value hence bool() converts it to False.

(ii) True: ‘0’ is string value, which is non-empty string and has a truth value, hence bool() convert it to True.

 

 

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post