SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
(continued from previous page)
rec_func(
6
)
>>> %Run -c $EDITOR_CONTENT
1
3
6
10
15
21
In this example, rec_func() is a function that we have defined to call itself (“recursion”). We use the
i
variable as
the data, and it will decrement (-1) every time we recurse. When the condition is not greater than 0 (that is, 0), the
recursion ends.
For new developers, it may take some time to determine how it works, and the best way to test it is to test and modify
it.
Advantages of Recursion
• Recursive functions make the code look clean and elegant.
• A complex task can be broken down into simpler sub-problems using recursion.
• Sequence generation is easier with recursion than using some nested iteration.
Disadvantages of Recursion
• Sometimes the logic behind recursion is hard to follow through.
• Recursive calls are expensive (inefficient) as they take up a lot of memory and time.
• Recursive functions are hard to debug.
3.5.9 Data Types
Built-in Data Types
MicroPython has the following data types:
• Text Type: str
• Numeric Types: int, float, complex
• Sequence Types: list, tuple, range
• Mapping Type: dict
• Set Types: set, frozenset
• Boolean Type: bool
• Binary Types: bytes, bytearray, memoryview
126
Chapter 3. For MicroPython User
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 ...