Site under construction! :3
Boolean (bool
) ξ―
The boolean
type represents a truth value. It has exactly two constant states: true
or false
.
The built-in function bool
will convert any value to a boolean, if the value can be interpreted as a boolean.
Operatorsξ―
not
ξ―
The boolean not
operator will be the opposite value of the boolean it receives.
- Truth table
a |
not a |
---|---|
T β | F β |
F β | T β |
and
ξ―
The boolean and
operator will be true
if and only if both inputs are true
, otherwise it will be false
.
- Truth table
a |
b |
a and b |
---|---|---|
T β | T β | T β |
T β | F β | F β |
F β | T β | F β |
F β | F β | F β |
Its negated form (nand
) is not included in the standard library as a keyword, but it can be achieved by using chained operators: not (a and b)
.
- Be aware of the placement of the brackets here, as
not a and b
is evaluated as(not a) and b
.
or
ξ―
The boolean or
operator will be true
if and only if at least one of the inputs is true
, otherwise it will be false
.
- Truth table
a |
b |
a or b |
---|---|---|
T β | T β | T β |
T β | F β | T β |
F β | T β | T β |
F β | F β | F β |
Its negated form (nor
) is not included in the standard library as a keyword, but it can be achieved by using chained operators: not (a or b)
.
- Be aware of the placement of the brackets here, as
not a or b
is evaluated as(not a) or b
.
xor
ξ―
The boolean xor
operator will be true
if and only if one, but not both of the inputs are true
, otherwise it will be false
.
- Truth table
a |
b |
a xor b |
---|---|---|
T β | T β | F β |
T β | F β | T β |
F β | T β | T β |
F β | F β | F β |
Its negated form (xnor
) is not included in the standard library as a keyword, but it can be achieved by using chained operators: not (a xor b)
.
- Be aware of the placement of the brackets here, as
not a xor b
is evaluated as(not a) xor b
.