EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #288 background imageLoading...
Page #288 background image
SunFounder ESP32 Starter Kit
>>> %Run -c $EDITOR_CONTENT
('pear', 'apple', 'grape')
Print two messages and specify the separator:
print("Hello", "how are you?", sep="---")
>>> %Run -c $EDITOR_CONTENT
Hello---how are you?
3.6.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 dont 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
print(x)
>>> %Run -c $EDITOR_CONTENT
lily
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
print(x,y,z)
>>> %Run -c $EDITOR_CONTENT
5 5 5.0
282 Chapter 3. For MicroPython User

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish