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 #289 background imageLoading...
Page #289 background image
SunFounder ESP32 Starter Kit
Get the Type
You can get the data type of a variable with the type() function.
x = 5
y = "hello"
z = 5.0
print(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
print(a, A)
>>> %Run -c $EDITOR_CONTENT
5 lily
3.6.5 If Else
Decision making is required when we want to execute a code only if a certain condition is satisfied.
if
if test expression:
statement(s)
Here, the program evaluates the test expression and executes the statement only when the test expression is True.
If test expression is False, then statement(s) will not be executed.
In MicroPython, indentation means the body of the if statement. The body starts with an indentation and ends with the
first unindented line.
Python interprets non-zero values as True”. None and 0 are interpreted as “False”.
if Statement Flowchart
3.6. 1.6 (Optional) MicroPython Basic Syntax 283

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