Python Program to Convert Decimal to Binary, Octal and Hexadecimal

Here you will get python program to convert decimal to binary, octal and hexadecimal.

Python provides inbuilt functions for conversion of one number system to another.

  • Convert decimal to binary using bin() function. In converted binary form 0b is present at the beginning.
  • Convert decimal to octal using oct() function. In converted octal form 0o is present at the beginning.
  • Convert decimal to hexadecimal using hex() function. In converted hexadecimal form 0x is present at the beginning.

Below program demonstrates that how we can do these conversions.

Python Program to Convert Decimal to Binary, Octal and Hexadecimal

Output

enter a decimal number: 11

binary form is 0b1011
octal form is 0o13
hexadecimal form is 0xb

Comment below if you have any queries regarding above program.

1 thought on “Python Program to Convert Decimal to Binary, Octal and Hexadecimal”

Leave a Comment

Your email address will not be published. Required fields are marked *