Created
June 28, 2018 17:57
-
-
Save oca159/4b9cf31f751593843b4bbcb83ecf84d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
The rgb() method is incomplete. | |
Complete the method so that passing in RGB decimal values will result in a hexadecimal representation being returned. | |
The valid decimal values for RGB are 0 - 255. Any (r,g,b) argument values that fall out of that range should be rounded to the closest valid value. | |
''' | |
def rgb(r, g, b): | |
round = lambda x: min(255, max(x, 0)) | |
return ("{:02X}" * 3).format(round(r), round(g), round(b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment