plot() Test Sheet

Exercises all plot() call signatures to verify rendering.

Cell 1: plot(y) — auto x

Simplest form: pass a single list of y values, x is 0, 1, 2, ...

import math
y = [math.sin(i * 0.3) for i in range(30)]
plot(y, title='Sine wave (auto x)', y_label='sin(x)')
print('done')

Cell 2: plot(x, y) — explicit x

Pass x and y as separate sequences.

x = [i * 0.2 for i in range(40)]
y = [math.exp(-0.1 * v) * math.cos(v) for v in x]
plot(x, y, title='Damped cosine', x_label='t', y_label='amplitude')
print('done')

Cell 3: plot(x, y1, y2) — multiple series

With 3+ args and equal-length first two args, the first is treated as x and the rest as y-series.

x = [i * 0.25 for i in range(32)]
y1 = [math.sin(v) for v in x]
y2 = [math.cos(v) for v in x]
plot(x, y1, y2, title='sin and cos', x_label='radians', y_label='value')
print('done')

Cell 4: Multiple plot() calls in one cell

Each plot() call in a cell produces its own panel below the cell, in order.

plot([1, 4, 9, 16, 25, 36], title='Squares', y_label='n^2')
plot([1, 2, 6, 24, 120, 720], title='Factorials', y_label='n!')
print('two plots rendered')

Cell 5: Iterable inputs

plot() accepts any numeric iterable: list, range, generator, tuple.

plot(range(20), title='range() as y input')
plot(tuple(i*0.5 for i in range(20)), title='Tuple / generator')
print('done')

Cell 6: Error handling

Bad inputs raise TypeError or ValueError with clear messages.

cases = [
    ('no args',        lambda: plot()),
    ('x,y unequal',    lambda: plot([1,2,3], [1,2])),
    ('non-numeric',    lambda: plot(['a','b','c'])),
    ('infinite value', lambda: plot([1, float('inf'), 3])),
]
for name, fn in cases:
    try:
        fn()
        print(f'{name}: no error (unexpected)')
    except (TypeError, ValueError) as e:
        print(f'{name}: {type(e).__name__}: {e}')
created 2026-05-29