The unofficial CircuitPython Reference

logical operators

description

Logical operators combine comparison statements into compound statements that ultimately return and True or False value.

syntax

OperatorDescriptionExample SyntaxExample Result
andsee if expression 1 and expression 2 are BOTH True(1 > 2) and (2 < 3)FALSE
orsee if either expression 1 or expression 2 are True(1 > 2) or (2 < 3)TRUE
notreturn the opposite value of True/False expressionnot (1 < 2)FALSE

methods

parameters

returns

example code

serial output:

see also: