python convert int to hex code example

Example 1: convert int to binary python

# Python program to convert decimal to binary 
    
# Function to convert Decimal number  
# to Binary number  
def decimalToBinary(n):  
    return bin(n).replace("0b", "")  
    
# Driver code  
if __name__ == '__main__':  
    print(decimalToBinary(8))  
    print(decimalToBinary(18))  
    print(decimalToBinary(7))  
    
Output:
1000
1001

Example 2: convert decimal to hex python

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

Example 3: how to convert int in python

score = 89
score = str(score)