Number to hex

Python, Math · Oct 9, 2020

Returns the hexadecimal representation of the given number.

  • Use hex() to convert a given decimal number into its hexadecimal equivalent.
def to_hex(dec):
  return hex(dec)
to_hex(41) # 0x29
to_hex(332) # 0x14c

More like this

  • Number to binary

    Returns the binary representation of the given number.

    Python, Math · Oct 7, 2020

  • Integer to roman numeral

    Converts an integer to its roman numeral representation. Accepts value between 1 and 3999 (both inclusive).

    Python, Math · Nov 2, 2020

  • Arithmetic progression

    Generates a list of numbers in the arithmetic progression starting with the given positive integer and up to the specified limit.

    Python, Math · Nov 2, 2020