Skip to content
Home » Python program to convert decimal number into binary, octal and hexadecimal

Python program to convert decimal number into binary, octal and hexadecimal

Below is the program to convert a decimal number into binary, octal and hexadecimal numbers

# to convert decimal number to binary,octal and hexadecimal
n=int(input("Enter a binary number:"))
print(bin(n),"in binary")
print(hex(n),"in hexadecimal")
print(oct(n),"in octal")

Output:

Enter a binary number:53
0b110101 in binary
0x35 in hexadecimal
0o65 in octal