Complementary colours are pairs of colours which, when combined or mixed, cancel each other out by producing a grayscale colour like white or black. When placed next to each other, they create the strongest contrast for those two colours. Complementary colours may also be called “opposite colours.”.
To find out pairs of complementary colours we can use a colour wheel. Colours which are at the opposite position on the colour wheel are complementary colours:
Complementary Colours Formula
When representing colours using the RGB colour code, we can use the following formula to work out the complementary RGB colour code:
Complementary Colours Algorithm
Our aim is to write a Python program, based on the INPUT, PROCESS and OUTPUT model in order to:
- INPUT: Ask the user to enter an RGB colour code
- PROCESS: Apply the complementary colour code formula to work out the RGB code of the complementary colour
- OUPUT: Display the complementary colour code on screen
Our code will be based on the following flowchart:
Casting
To complete this challenge, you will need to understand the importance of casting values from string to integer data types using the int() function and from integer to string using the str() function.
Python Code
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area