EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #291 background imageLoading...
Page #291 background image
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

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish