Convert Binary to Hexadecimal

This is a simple Python script to convert binary to hexadecimal. The program asks the user to input the binary number, In Python we have built in functions to convert hexadecimal number, just use hex() function to convert any number. So we don't have to worry about the mathematics behind how to convert decimal numbers to hexadecimal.

#Getting input from the user
binary = input("Enter number in Binary Format: ")
temp = int(binary, 2)
print(binary,"in Hexadecimal =",hex(temp)[2:],"\n")
Enter number in Binary Format: 000100101111
000100101111 in Hexadecimal = 12f 

Post a comment


Your Comment

Email (We dont publish it)


Nothing the first to share wisdom.