Decimal to hexadecimal conversion in one line by R4R Team

Hexadecimal number

-It is a number which expressed in the base-16 numeral system,
-Hexadeciaml numbers range is 0 to 15

Decimal number

- A number which expressed in the base-10 numeral system.
- Decimal number range is 0 to 9

Conversion of Decimal to Hexadecimal number
Example-
Decimal number - 10
Its Hexa equivalent is- A

Decimal number - 16
Its Hexa equivalent is 10

program -

print("Octal equivalent is - "+hex(int(input("Enter Decimal numbern"))))


output -

Enter Decimal number
10
Octal equivalent is - 0xa

Enter Decimal number
345
Octal equivalent is - 0x159


-In this program, we use hex() function which is in-build function in python which find the hexadecimal equivalent of the given decimal number and in output 0x show that this is hexadecimal number.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!