Raspberry_Pi_Education_Manual

Notes:

Try making up your own colours.

>>> PiColour = (123,456,789) >>> surface.fill(PiColour) >>> pygame.display.update()

Argh! Now that wasn’t fun. You created a bad colour and Python has told you (in American).

TypeError: invalid color argument

You will have to watch for American spellings like these when writing commands to computers, as a lot of computing standards are developed in the USA.

Python is telling you that the colour tuple is not valid. The PyGame documentation says that the colour tuple must only have values from 0 to 255. Each number represents how much red, green or blue you want in the colour (in that order). Mixing these will give you every colour that the computer can display. That’s 256 x 256 x 256 different colours. Try typing this at the prompt to get the answer to that product.

>>> 256 * 256 * 256

Or even:

>>> 256 ** 3

The symbols ** mean “raised to the power of”. Notice that I haven’t used “print()”. Python can be a great calculator, too!

The computer can display 256 x 256 x 256 colours.

That’s 16,777,216 different colours!

A beginner’s guide to Scratch

76

Made with FlippingBook flipbook maker