SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
>>> %Run -c $EDITOR_CONTENT
10
9
8
7
6
While Loop with Else
Like the
if
loop, the
while
loop can also have an optional
else
block.
If the condition in the
while
loop is evaluated as
False
, the
else
part is executed.
x
=
10
while
x
>
0
:
(x)
x
-=
1
else
:
(
"Game Over"
)
>>> %Run -c $EDITOR_CONTENT
10
9
8
7
6
5
4
3
2
1
Game Over
3.5.7 For Loops
The
for
loop can traverse any sequence of items, such as a list or a string.
The syntax format of for loop is as follows:
for
val
in
sequence:
Body of
for
Here,
val
is a variable that gets the value of the item in the sequence in each iteration.
The loop continues until we reach the last item in the sequence. Use indentation to separate the body of the
for
loop
from the rest of the code.
Flowchart of for Loop
118
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 ...