Home >>Python Programs >Python Program to Convert Decimal to Binary Octal and Hexadecimal
In this example, we will see a Python program to convert any decimal number into a binary, octal or hexadecimal. Decimal system has base 10, Binary system has the base 2, Octal system has the base 8 and Hexadecimal system has the base 16.
Example :
dec = int(input("Enter a decimal number: "))
print(bin(dec),"in binary.")
print(oct(dec),"in octal.")
print(hex(dec),"in hexadecimal.")