RGBA Color Dtype

easynumpy_basics

Implement rgba_dtype().

Return a custom NumPy structured dtype that describes a color as four unsigned bytes: fields named "r", "g", "b", "a", each an unsigned 8-bit integer (np.uint8). The dtype should occupy 4 bytes in total.

Your solution

Edit rgba_dtype and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

np.dtype([(name, type), ...]) builds a structured dtype; np.uint8 is an unsigned byte.