print bool in python code example

Example 1: python bool()

# Returns the boolean value of the specified object
x = bool(1) # outputs True

Example 2: boolean python example

#Example I found:

my_boolean = 1
print(bool(my_boolean))

my_boolean = 0
print(bool(my_boolean))

my_boolean = 10
print(bool(my_boolean))

print("Coding" == "fun")

Example 3: python print bool as string

isFoo = True // our bool variable

// now we use str() to cast bool to string
print('Value of isFoo is: ' + str(isFoo)) // Value of isFoo is: True

// common mistake just for example. Don't do that
print('Value of Foo is: ' + isFoo) // TypeError: can only concatenate str (not "bool") to str