# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="qrPu6JyW-2C8" colab_type="text"
# **Decimal to Hexadecimal**
#
# ---
#
#

# + id="Y1SMyok99oWS" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 34} outputId="c1dfff8f-1ae5-434d-fc04-a028291dabf9"
dec_num = 254
print('{:X}'.format(dec_num))

# + [markdown] id="FjNZAGWQ_vem" colab_type="text"
# Note that I have used the format() function here together with the {:X} placeholder which tells Python to print the number as Hexadecimal.
#
# There is a hex() function available but it prepends the output with "0x" which may be a nuisance for what you are doing.

# + [markdown] id="fDTIzrBD-9K7" colab_type="text"
# **HexHexadecimal to Decimal**
#
# ---
#
#

# + id="eqQwnxam9yZT" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 34} outputId="1abb9e87-fec8-4035-858e-b42d5666cd53"
hex_string = 'FE'
print(int(hex_string, 16))

# + [markdown] id="vYBiYRSW_a3A" colab_type="text"
# Note the use of ", 16" in the int() function? That tells python that we are converting from  a Hex string as opposed to an integer string.

# + [markdown] id="hj7pW8hSJO20" colab_type="text"
# The original of this file can be found at https://colab.research.google.com/drive/1LhwqcRlAbCs1JTLagCLsjC3WdwrKGsW8

StarcoderdataJupyterScriptsDedupFiltered