# Python Program to Convert Decimal into Binary, Octal, and Hexadecimal

Python Program to Convert Decimal into Binary, Octal, and Hexadecimal

We know that the most widely used number system is a decimal system, but the computer only understands binary values. The binary, octal, and hexadecimal number systems are related to each other. The binary system has base 2, octal has base 8, hexadecimal has base 16, and decimal system is base 10.

Decimal number: It is the most commonly used number system. It is the base 10 that used (0 – 9) to represent a number.

Binary System: The base 2 number system is the binary number system. This number system is used because the computer understands numbers in the form of 0 and 1 only. A number with the prefix ‘0b’ is considered binary.

Octal System: The base 8 number represents the octal system. A number with the prefix ‘0o’ is considered octal.

Hexadecimal system: The base 16 number represents the hexadecimal system. A number with the prefix ‘0x’ considered hexadecimal. For example:

` 60 = 0b11100 = 0o74 = 0x3c `

Source Code

The below is a source code that converts the decimal number into binary, octal, and hexadecimal number.

```#Program to convert decimal into binary, octal, hexadecimal
#Choose a decimal number
decimal = int(input("Enter decimal number: "))
print("The binary value of",decimal,"is",bin(decimal))
print("The octal value of",decimal,"is",oct(decimal))