⊕
⊖
Contents
Convert Hex to Decimal
To convert a given hexadecimal number to a decimal number in Python, call the builtin function int() and pass the hex number, and base=16 as arguments. int() converts the given value using the specified base, and returns the decimal number.
Example
In this example, we write a function to read a decimal number from user, convert it to hex, and print the result to standard output.
Output #1
Enter hex : A2
Decimal : 162
Output #2
Enter hex : FFFA
Decimal : 65530
Summary
In this Python Examples tutorial, we learned how to convert hexadecimal number to decimal number using int() builtin function.