How it works...

In this recipe, we use the random module, which is part of the Python standard library and CircuitPython. Calling randint and providing a range from 0 to 255 will give us a random integer for each color component.

We then define the get_random_color function to randomly select each of the three color components and, therefore, make a random color. Now that we have this function, we can call it to set the color of a single pixel or all the pixels, as demonstrated in the final two code snippets in this recipe.