Question:Write a program to convert decimal to binary, octal and hexadecimal using inbuilt functions

**Program:**

1 2 3 4 5 6 7 | # Python program to convert decimal number into binary, octal and hexadecimal number system # Take decimal number from user dec = int(input("Enter an integer: ")) print("The decimal value of",dec,"is:") print(bin(dec),"in binary.") print(oct(dec),"in octal.") print(hex(dec),"in hexadecimal.") |

**Explanation:**

A binary number is a number expressed in the binary numeral system or base-2 numeral system which represents numeric values using two different symbols: typically 0 (zero) and 1 (one). The base-2 system is a positional notation with a radix of 2.

The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7. Octal numerals can be made from binary numerals by grouping consecutive binary digits into groups of three (starting from the right). For example, the binary representation for decimal 74 is 1001010.

Hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a, b, c, d, e, f) to represent values ten to fifteen.

**Output:**

1 2 3 4 5 | Enter an integer: 56 The decimal value of 56 is: 0b111000 in binary. 0o70 in octal. 0x38 in hexadecimal. |

## Leave a Reply