Boolean

A boolean variable can have one of two values: true or false. Booleans are often used to control the flow of code and express logic. This code assigns the Boolean value of true to the variable foo, then prints this value:

foo = true
print ("The value of foo is:")
print (foo)

A more useful example of a Boolean is to obtain it from some kind of logical operation, for example, to check whether five is greater than three or not. This code demonstrates how to do this:

result = 5 > 3
print ("Is 5 > 3?")
print (result)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.46.92