Complementary colors are pairs of colors which, when combined or mixed, cancel each other out by producing a grayscale color like white or black. When placed next to each other, they create the strongest contrast for those two colors. Complementary colors may also be called “opposite colors.”.
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 comlpementary colour
- OUPUT: Display the complementary colour code on screen
Our code will be based on the following flowchart:
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.