CircuitPython Built-Ins
CircuitPython comes 'with the kitchen sink' - a lot of the things you know and love about classic Python 3 (sometimes
called CPython) already work. There are a few things that don't but we'll try to keep this list updated as we add more
capabilities!
This is not an exhaustive list! It's simply some of the many features you can use.
Thing That Are Built In and Work
Flow Control
All the usual
,
,
if
elif
else
Math
will give you a range of handy mathematical functions.
import math
>>> dir(math)
['__name__', 'e', 'pi', 'sqrt', 'pow', 'exp', 'log', 'cos', 'sin', 'tan', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'copysign', 'fabs',
'floor', 'fmod', 'frexp', 'ldexp', 'modf', 'isfinite', 'isinf', 'isnan', 'trunc', 'radians', 'degrees']
CircuitPython supports 30-bit wide floating point values so you can use
Tuples, Lists, Arrays, and Dictionaries
You can organize data in
Classes, Objects and Functions
We use objects and functions extensively in our libraries so check out one of our many examples like this
library
(https://adafru.it/BfQ)
Lambdas
Yep! You can create function-functions with
>>> g = lambda x: x**2
>>> g(8)
64
Random Numbers
To obtain random numbers:
import random
will give a floating point number from
random.random()
random.randint( min , max )
© Adafruit Industries
,
,
work just as expected.
for
while
,
, and
including strings, objects, floats, etc.
()
[]
{}
for class examples.
lambda
will give you an integer number between
https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51
and
int
just the way you like em:
to
.
0
1.0
and
min
whenever you expect.
float
.
max
Page 104 of 183
MCP9808
Need help?
Do you have a question about the Feather M4 Express and is the answer not in the manual?