SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
3.5.3 Print()
The
print()
function prints the specified message to the screen, or other standard output device. The message can
be a string, or any other object, the object will be converted into a string before written to the screen.
Print multiple objects:
(
"Welcome!"
,
"Enjoy yourself!"
)
>>> %Run -c $EDITOR_CONTENT
Welcome! Enjoy yourself!
Print tuples:
x
=
(
"pear"
,
"apple"
,
"grape"
)
(x)
>>> %Run -c $EDITOR_CONTENT
('pear', 'apple', 'grape')
Print two messages and specify the separator:
(
"Hello"
,
"how are you?"
, sep
=
"---"
)
>>> %Run -c $EDITOR_CONTENT
Hello---how are you?
3.5.4 Variables
Variables are containers used to store data values.
Creating a variable is very simple. You only need to name it and assign it a value. You don’t need to specify the data
type of the variable when assigning it, because the variable is a reference, and it accesses objects of different data types
through assignment.
Naming variables must follow the following rules:
• Variable names can only contain numbers, letters, and underscores
• The first character of the variable name must be a letter or underscore
• Variable names are case sensitive
Create Variable
There is no command for declaring variables in MicroPython. Variables are created when you assign a value to it for
the first time. It does not need to use any specific type declaration, and you can even change the type after setting the
variable.
x
=
8
# x is of type int
x
=
"lily"
# x is now of type str
(x)
>>> %Run -c $EDITOR_CONTENT
lily
3.5. MicroPython Basic Syntax
111
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 ...