How do i convert the decimal value into formatted Binary value and Hex value
usually i do it this way
binary = lambda n: '' if n==0 else binary(n/2) + str(n%2)
print binary(17)
>>>> 10001
print binary(250)
>>>> 11111010
but i wanted to have 8 binary digits for any value given (0-255 only) i.e. I need to append '0' to the beginning of the binary number like the examples below
7 = 0000 1111
10 = 0000 1010
250 = 1111 1010
and even i need to convert to the hex starting with 0x
7 = 0x07
10 = 0x0A
250 = 0xFA