Write a Python program to convert the Decimal Number into binary.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Defining the function to convert Decimal Number to binary def Decimal_2_binary(T4Tutorials): Decimal_Number = int(T4Tutorials) # Displaying the equivalent Decimal_Number print ("The given Decimal number", Decimal_Number, "in Binary number is: ", bin(Decimal_Number)) # we will define the function to convert Decimal_Number to octal def Decimal_2_octal(T4Tutorials
): Decimal_Number = int(T4Tutorials) # Then, print the equivalent Decimal_Number print ("The given Decimal number", Decimal_Number, "in Octal number is: ", oct(Decimal_Number)
) # we will define the function to convert Decimal_Number to hexaDecimal_Number def Decimal_2_hexaDecimal(T4Tutorials): Decimal_Number = int(T4Tutorials) # Then, print the equivalent Decimal_Number print ("The given Decimal number", Decimal_Number, " in HexaDecimal_Number number is: ", hex(Decimal_Number)) # Driver program T4Tutorials = int (input (" Please! Enter the Decimal_Number Number: ")) Decimal_2_binary(T4Tutorials) Decimal_2_octal(T4Tutorials) Decimal_2_hexaDecimal(T4Tutorials) |
Output
Please! Enter the Decimal Number: 19
The given Decimal number 19 in Binary number is: 0b10011
The given Decimal number 19 in Octal number is: 0o23
The given Decimal number 19 in HexaDecimal_Number number is: 0x13