# Decimal to hexadecimal conversion in python by R4R Team

-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 -

n=int(input("Enter decimal numbern"))
s=""
while(n):
t=n%16
if t==10:
t="A"
if t==11:
t="B"
if t==12:
t="C"
if t==13:
t="D"
if t==14:
t="E"
if t==15:
t="F"
s=s+str(t)
n=int(n/16)
print(s[::-1])

output-

Enter decimal number
16
Its Hexa equivalent is - 10

Enter decimal number
234
Its Hexa equivalent is - EA

-In this program, firstly we take input of decimal number then using 1st while loop, we break the decimal into hexa bits and store those bit in list and in 2nd while loop, we traverse the list in reverse order and add to 'hexa' variable and this variable have the hexa equivalent of given number.