Computer Science, asked by sdheerpalia, 1 year ago

how to convert a decimal expression into hexadecimal in python ​

Answers

Answered by Anonymous
0

Answer:

Convert Hexadecimal to Decimal in Python

To convert hexadecimal to decimal number in python, you have to ask from user to enter hexadecimal number to convert that number into decimal number as shown in the program given below.

Python Programming Code to Convert Hexadecimal to Decimal

Following python program ask from user to enter any number in hexadecimal format to convert it into decimal format:

# Python Program - Convert Hexadecimal to Decimal

print("Enter 'x' for exit.");

hexdec = input("Enter number in Hexadecimal Format: ");

if hexdec == 'x':

   exit();

else:

   dec = int(hexdec, 16);

   print(hexdec,"in Decimal =",str(dec));

Similar questions