Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert decimal to hex python

    hex(x) being x the integer you want to convert
Comment

converting decimal to hex in python

# plz suscribe to my youtube channel -->
# https://www.youtube.com/channel/UC-sfqidn2fKZslHWnm5qe-A

def convert_to_hex(number:int):
    if number == None:
        return "Invalid input"
    elif type(number) == float:
        return "Float not handled"
    elif type(number) == str:
        temp = int(number)
        return format(temp, "02x")
    return format(number, '02x')
print(convert_to_hex(30))
print(convert_to_hex(None))
print(convert_to_hex("7"))
print(convert_to_hex(7.09))
Comment

python convert hex number to decimal

print(int("61", 16)) # output 97 (ascii value "a")
Comment

PREVIOUS NEXT
Code Example
Python :: application/x-www-form-urlencoded python 
Python :: after groupby how to add values in two rows to a list 
Python :: input command in python shell 
Python :: How to recursively sort the elements of a stack, in Python? 
Python :: how to store in parquet format using pandas 
Python :: how to close opencv window in python 
Python :: scipy euclidean distance 
Python :: how to make a venv python 
Python :: generate list of consecutive numbers 
Python :: isnumeric 
Python :: delete values with condition in numpy 
Python :: get just filename without extension from the path python 
Python :: read files and write into another files python 
Python :: python closure 
Python :: python remove whitespace from start of string 
Python :: set header in dataframe 2nd line 
Python :: python replace string 
Python :: how to take input in python 
Python :: tkinter template 
Python :: change font size in plt 
Python :: number of words in a string python 
Python :: if __name__ == 
Python :: python unzip a zip 
Python :: how to run linux command in python 
Python :: python remove first element from list 
Python :: Converting uint8 into integers 
Python :: custom keyboard telegram bot python 
Python :: how to mention a div with class in xpath 
Python :: tasks discord py 
Python :: how to use if else in lambda python 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =