SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
–
Case sensitive.
• Parameters (arguments) through which we pass values to a function. They are optional.
• The colon (:) marks the end of the function header.
• Optional docstring, used to describe the function of the function, we usually use triple quotes so that the doc-
string can be expanded to multiple lines.
• One or more valid Micropython statements that make up the function body. Statements must have the same
indentation level (usually 4 spaces).
• Each function needs at least one statement, but if for some reason there is a function that does not contain any
statement, please put in the pass statement to avoid errors.
• An optional
return
statement to return a value from the function.
Calling a Function
To call a function, add parentheses after the function name.
def
my_function
():
(
"Your first function"
)
my_function()
>>> %Run -c $EDITOR_CONTENT
Your first function
The return Statement
The return statement is used to exit a function and return to the place where it was called.
Syntax of return
return
[expression_list]
The statement can contain an expression that is evaluated and returns a value. If there is no expression in the statement,
or the
return
statement itself does not exist in the function, the function will return a
None
object.
def
my_function
():
(
"Your first function"
)
(my_function())
>>> %Run -c $EDITOR_CONTENT
Your first function
None
Here,
None
is the return value, because the
return
statement is not used.
122
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 ...