You can create functions that returns a Boolean Value:
ExamplePrint the answer of a function:
def myFunction() :
return True
print(myFunction())
Try it Yourself »You can execute code based on the Boolean answer of a function:
ExamplePrint "YES!" if the function returns True, otherwise print "NO!":
def myFunction() :
return True
if myFunction():
print("YES!")
else:
print("NO!")
Try it Yourself »Python also has many built-in functions that returns a boolean value, like the isinstance()
function, which can be used to determine if an object is of a certain data type:
Check if an object is an integer or not:
x = 200
print(isinstance(x, int))
Track your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4