大象传媒

Boolean operations

are used to combine relational operators to give more complex decisions.

Boolean operationOperatorExample
AndANDIF x > 0 AND x < 10
OrORIF topic = "Computing" OR topic = "Computer Science"
NotNOTWHILE NOT x
Boolean operationAnd
OperatorAND
ExampleIF x > 0 AND x < 10
Boolean operationOr
OperatorOR
ExampleIF topic = "Computing" OR topic = "Computer Science"
Boolean operationNot
OperatorNOT
ExampleWHILE NOT x

The code below uses two conditions to check if the password entered is both the correct length of six or more characters and is not a number:

password 鈫 USERINPUT
IF LEN(password) >= 6 AND IS_NUMERIC(password) 
= False THEN
     OUTPUT 鈥淕ood Password!鈥
ELSE
    OUTPUT 鈥淧assword too short鈥
ENDIF