SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
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.
if. . . elif. . . else Statement Flowchart
Example
if
x
>
y:
(
"x is greater than y"
)
elif
x
==
y:
(
"x and y are equal"
)
(continues on next page)
3.5. MicroPython Basic Syntax
115
Summary of Contents for Thales Kit
Page 1: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 Jimmy SunFounder Jun 04 2021 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 CONTENTS ...
Page 140: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 136 Chapter 3 For MicroPython User ...
Page 164: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 160 Chapter 4 For Arduino User ...