Skip to content

Instantly share code, notes, and snippets.

@pmutua
Created April 25, 2017 13:33
Show Gist options
  • Save pmutua/968150246b11b2d6f460b335bcfc9b3e to your computer and use it in GitHub Desktop.
Save pmutua/968150246b11b2d6f460b335bcfc9b3e to your computer and use it in GitHub Desktop.
Algorithm to convert decimal numbers between 0 and 255 to their binary equivalents.
def binary_converter(dec):
if dec < 0 or dec > 255:
return "Invalid input";
return "{0:b}".format(dec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment