C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Python bool() FunctionThe python bool() method converts value to boolean (True or False) using the standard truth testing procedure. Signaturebool([value]) ParametersIt is not mandatory to pass value to bool(). If you do not pass the value, bool() returns False. In general , bool() takes a single parameter value. ReturnThe bool() returns:
Python bool() Function Exampletest = [] print(test,'is',bool(test)) test = [0] print(test,'is',bool(test)) test = 0.0 print(test,'is',bool(test)) test = None print(test,'is',bool(test)) test = True print(test,'is',bool(test)) test = 'Easy string' print(test,'is',bool(test)) Output: [] is False [0] is True 0.0 is False None is False True is True Easy string is True
Next TopicPython Built in Functions
|