Python : Using Hex Colour Codes

colour creation.PNG

Colourful-Code Creations - Project 2

In this project you’ll create a dictionary of colors which maps hard to recollect shade codes into friendly names. Python turtle have predefined shades such as ‘red’ and ‘white’ but you may also use hex color codes (you could have visible these within the HTML & CSS course.)Using hex color codes is surely flexible but they are tough to remember.

As you in all likelihood already know, a dictionary allows you to appearance up a word, and spot it’s meaning. In Python, a dictionary is even more flexible than that – it lets in you to look up a value for any ‘key’ in the dictionary.Let’s create a dictionary to map from human-friendly shade names (keys) to computer-friendly hex codes (values). 

Choose cool names for your colours and edit the colours = line to add entries to the dictionary for them.

Here’s an example colour dictionary:

colours = { 

  ‘space’: ‘#060608’, 

  ‘moongrey’: ‘#BCBDEF’

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Categories

Leave a Reply

Your email address will not be published. Required fields are marked *