Conditions

conditions

Conditions

Video Transcript

In this this section, we're going to learn about conditions.
A condition is an expression that can be evaluated as either True or False. This is done using comparison operators, logic operators, and booleans.
Many of the comparison operators might be familiar from your math class. These include:
Operator Meaning
< less than
<= less than or equal
> greater than
>= greater than or equal
== equal
!= not equal
For example, the expression 15 < 20 would be True because 15 is indeed less than 20, and "hello" == "goodbye" would be False because the phrases "hello" and "goodbye" are not the same.
We can also use the logic operators not (to turn an expression from True to False and vice versa), and (to combine two expressions that must both be True), and or (to combine two expressions where at least one must be True).
Booleans are another type of variable which can only have one of two values, either True or False.
Last section Next section