DEV Community


converting from decimals to binary in Python

Tony Colston
wanna be gamedev ... all around nerd and dev
・1 min read

I started listening to this podcast

Which so far seems like a good podcast to listen to if you are starting to learn about Computer Science. Or just want a refresh.

While listening to the first episode I wondered ...

In Python how do you convert into hex or binary from a decimal number?

a = 43
# now binary
# now hex

The functions bin and hex will convert a number into a string representation for binary and hexadecimal.

Discussion (0)