Skip to content

API Reference

Basic math operations.

add(a, b)

Add two numbers.

Parameters:

Name Type Description Default
a int or float

The first number.

required
b int or float

The second number.

required

Returns:

Type Description
int or float

The sum of a and b.

Raises:

Type Description
TypeError

If a or b is not a number.

Examples:

>>> add(1, 2)
3

fibonacci(n)

Generate the Fibonacci sequence.

Parameters:

Name Type Description Default
n int

The number of terms to generate. Must be non-negative.

required

Returns:

Type Description
list of int

The first n terms of the Fibonacci sequence.

Raises:

Type Description
ValueError

If n is negative.

Examples:

>>> fibonacci(6)
[0, 1, 1, 2, 3, 5]