Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Adafruit Logo
0
Adafruit Trinket M0 CircuitPython Built-Ins

Adafruit Trinket M0

CircuitPython or Arduino IDE on this tiny little microcontroller board

Image for user adafruit2
published August 23, 2017, last edited June 24, 2025
Save Link Note Download
161
Beginner
Product guide

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 usualif,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 useint andfloat 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 thisMCP9808 library for class examples.

Lambdas

Yep! You can create function-functions withlambda 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 from0 to1.0.

random.randint(min,max) will give you an integer number betweenmin andmax.

Page last edited March 08, 2024

Text editor powered bytinymce.

Related Guides
Search

Search

Categories

[8]ページ先頭

©2009-2025 Movatter.jp