# 7 examples of 'python hexadecimal to decimal' in Python

Every line of 'python hexadecimal to decimal' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

## All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
``26def _hex2dec(s):27	return str(int(s,16))``
``30def hex2dec(hex):31    """ Convert and hex value in a decimal number32    """33    return int(hex, 16)``
``5def toHex(self, num):6    """7    :type num: int8    :rtype: str9    """10    if not num:11        return "0"1213    result = []14    while num and len(result) != 8:15        h = num &amp; 1516        if h &lt; 10:17            result.append(str(chr(ord('0') + h)))18        else:19            result.append(str(chr(ord('a') + h-10)))20        num &gt;&gt;= 421    result.reverse()2223    return "".join(result)``
``33def test_dec_to_hex(self):34    self.assertEqual(conversion.decimal_to_hex(30), '1E')``
``182def decodeaDecimal(bv, validate=False):183    return Decimal(binary.signedIntFromBV(bv[78:94]))/Decimal('10')``
``96def dec_to_hex(dec):97    return str(format(dec, "x"))``
``894def hex2char(hexadec):895    """Answers the unicode char that matcher the hex value. Answer None if896    conversion fails.897898    &gt;&gt;&gt; hex(ord('A'))899    '0x41'900    &gt;&gt;&gt; hex2dec('41')901    65902    &gt;&gt;&gt; hex2char('41')903    'A'904    &gt;&gt;&gt; hex2char('FFZ') is None905    True906    """907    v = hex2dec(hexadec)908    if v is not None:909        return chr(v)910    return None``