Number bases (binary & hex)
easy 14 minEvery number base works the same way: each digit is multiplied by the base raised to the power of its position.
Number bases in Python: by hand and with the built-ins
Read it, run it, change a line and run it again.
Loading editor…
to_base and from_base are the division and Horner methods for any base from 2 to 16; hex_to_bin and bin_to_hex swap hex digits and 4-bit nibbles directly.