
SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
Casting
If you want to specify the data type for the variable, you can do it by casting.
x
=
int
(
5
)
# y will be 5
y
=
str
(
5
)
# x will be '5'
z
=
float
(
5
)
# z will be 5.0
(x,y,z)
>>> %Run -c $EDITOR_CONTENT
5 5 5.0
Get the Type
You can get the data type of a variable with the
type()
function.
x
=
5
y
=
"hello"
z
=
5.0
(
type
(x),
type
(y),
type
(z))
>>> %Run -c $EDITOR_CONTENT
<class 'int'> <class 'str'> <class 'float'>
Single or Double Quotes?
In MicroPython, single quotes or double quotes can be used to define string variables.
x
=
"hello"
# is the same as
x
=
'hello'
Case-Sensitive
Variable names are case-sensitive.
a
=
5
A
=
"lily"
#A will not overwrite a
(a, A)
>>> %Run -c $EDITOR_CONTENT
5 lily
112
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 ...