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 #293 background imageLoading...
Page #293 background image
SunFounder ESP32 Starter Kit
Nested if
We can embed an if statement into another if statement, and then call it a nested if statement.
Example
x = 67
if x > 10:
print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
>>> %Run -c $EDITOR_CONTENT
Above ten,
and also above 20!
3.6.6 While Loops
The while statement is used to execute a program in a loop, that is, to execute a program in a loop under certain
conditions to handle the same task that needs to be processed repeatedly.
Its basic form is:
while test expression:
Body of while
In the while loop, first check the test expression. Only when test expression evaluates to True, enter the body
of the while. After one iteration, check the test expression again. This process continues until test expression
evaluates to False.
In MicroPython, the body of the while loop is determined by indentation.
The body starts with an indentation and ends with the first unindented line.
Python interprets any non-zero value as True. None and 0 are interpreted as False.
while Loop Flowchart
3.6. 1.6 (Optional) MicroPython Basic Syntax 287

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