EasyManua.ls Logo

Adafruit Feather M4 Express - Circuitpython Built-Ins; Thing that Are Built in and Work

Adafruit Feather M4 Express
178 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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!
Thing That Are Built In and Work
Flow Control
All the usual if , elif , else , for , while work just as expected.
Math
import math will give you a range of handy mathematical functions.
>>> 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 int and float whenever you expect.
Tuples, Lists, Arrays, and Dictionaries
You can organize data in () , [] , and {} including strings, objects, floats, etc.
Classes, Objects and Functions
We use objects and functions extensively in our libraries so check out one of our many examples like this MCP9808
library (https://adafru.it/BfQ) for class examples.
Lambdas
Yep! You can create function-functions with lambda just the way you like em:
>>> g = lambda x: x**2
>>> g(8)
64
Random Numbers
To obtain random numbers:
import random
random.random() will give a floating point number from 0 to 1.0 .
random.randint(
min
,
max
) will give you an integer number between min and max .
This is not an exhaustive list! It's simply some of the many features you can use.
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51 Page 104 of 183

Table of Contents

Related product manuals