July 2018
Beginner
202 pages
5h 42m
English
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 = trueprint ("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 > 3print ("Is 5 > 3?")print (result)