C The Library at a Glance
Everything that comes with Zeno, on a few pages. The chapter that explains each part is named beside it.
Functions that need no import
| Function | Gives |
|---|---|
print(a, b, ...) |
shows the values on one line, with spaces between |
input(),
input(question) |
the next line typed, or none
at the end (23) |
len(x) |
how many items, characters or keys |
range(stop),
range(start, stop, step) |
a list of whole numbers (7) |
int(x),
float(x), str(x) |
the value as another type;
int and float of text may raise
ValueError |
char(n) |
the character with Unicode number
n |
abs(x) |
x without its sign (24) |
min(...),
max(...) |
the smallest or largest, of numbers or of a list |
sum(xs) |
a list of numbers added up |
u8(n) and u16,
u32, i8, i16,
i32 |
n as a sized number, or
OverflowError (18) |
u8.wrap(n) and the
others |
the low bits of n, never
failing |
allocate(T, n),
free(p) |
memory by hand (33) |
Text: str
| Method | Gives (6) |
|---|---|
upper(),
lower() |
capitals or small letters, a to z only |
strip() |
without blanks at either end |
split(),
split(sep) |
a list of words, or of the pieces between
each sep |
lines() |
a list of the lines |
replace(old, new) |
every old made
new |
starts_with(s),
ends_with(s) |
bool |
find(s) |
a position, or none |
slice(from, to),
slice(from) |
a part |
code() |
the Unicode number of a one-character text |
Lists: list[T]
| Method | Does (9) |
|---|---|
append(x),
insert(at, x) |
adds an item |
pop(),
pop(at) |
takes out the last item, or the one at
at, and gives it |
clear() |
takes out every item |
reverse(),
sort() |
in place |
find(x) |
a position, or none |
slice(from, to),
slice(from) |
a new list of a part |
join(sep) |
for text: one text with sep
between |
map(f),
filter(f) |
a new list |
reduce(f, start) |
one value |
Dicts: dict[K, V]
| Written | Does (10) |
|---|---|
d[key],
d[key] = v |
reads (or KeyError),
stores |
key in d |
is it there? |
get(key),
get(key, instead) |
the value, or none, or
instead |
pop(key) |
takes the key out and gives its value |
keys(),
values() |
new lists, in the order the keys came |
clear() |
takes every key out |
The modules
| Name | Is |
|---|---|
import math (24) |
|
pi, e |
the numbers |
sqrt(x) |
square root |
floor(x),
ceil(x), round(x) |
to a whole number, an
int |
sin, cos,
tan |
of an angle, deg,
rad or a plain number |
asin, acos,
atan, atan2(y, x) |
an angle in rad |
exp(x), log(x),
log2(x), log10(x) |
powers of e and logarithms |
import time (17) |
|
sleep(t) |
waits; t has a unit of
time |
now() |
a clock that only goes forward, in
ms |
import board (27) |
|
led |
the pin of the LED |
pin(n) |
the pin with that number |
register(T, address) |
a register of size T |
p.on(), off(),
toggle(), is_on(), number |
what a Pin does |
r.read(),
r.write(v), r.address |
what a Register does, inside
unsafe |
import files (23) |
|
read(path) |
the whole file, as text |
write(path, text),
append(path, text) |
writes, or adds to the end |
exists(path) |
bool |
remove(path) |
removes the file |
import program
(23) |
|
arguments() |
the words after the file |