SunFounder ESP32 Starter Kit
Example
num = -8
if num > 0:
print(num, "is a positive number.")
else:
print(num, "is a negative number.")
>>> %Run -c $EDITOR_CONTENT
-8 is a negative number.
if. . . elif. . . else
if test expression:
Body of if
elif test expression:
Body of elif
else:
Body of else
Elif is short for else if. It allows us to check multiple expressions.
If the condition of the if is False, the condition of the next elif block is checked, and so on.
If all conditions are False, the body of else is executed.
Only one of several if. .. elif. . .else blocks is executed according to the conditions.
The if block can only have one else block. But it can have multiple elif blocks.
3.6. 1.6 (Optional) MicroPython Basic Syntax 285