
SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
(continued from previous page)
else
:
(
"x is greater than y"
)
>>> %Run -c $EDITOR_CONTENT
x is greater than y
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
:
(
"Above ten,"
)
if
x
>
20
:
(
"and also above 20!"
)
else
:
(
"but not above 20."
)
>>> %Run -c $EDITOR_CONTENT
Above ten,
and also above 20!
3.5.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
116
Chapter 3. For MicroPython User
Содержание Thales Kit
Страница 1: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 Jimmy SunFounder Jun 04 2021 ...
Страница 2: ......
Страница 4: ...ii ...
Страница 6: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 CONTENTS ...
Страница 10: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 6 Chapter 1 Introduction to Raspberry Pi Pico ...
Страница 12: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 8 Chapter 2 What is Included in This Kit ...
Страница 13: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 1 Components List 2 1 Components List 9 ...
Страница 42: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 38 Chapter 2 What is Included in This Kit ...
Страница 140: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 136 Chapter 3 For MicroPython User ...
Страница 164: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 160 Chapter 4 For Arduino User ...