Hackbright Code Challenges

Hexadecimal Conversion

Hexadecimal Conversion

Whiteboard

Harder

Challenge

Medium

Concepts

Math, General

Download

hex-convert.zip

Solution

Hexadecimal Conversion: Solution


Hexadecimal is a numbering system that uses base 16, rather than the base 10 of our normal numbering system. Therefore, there are digits from 0-9 and A-F. (Hexadecimal is an important concept in computer science, and you can learn more about it at the Wikipedia article about hexadecimal)

Write a function that, when given a hexadecimal number as a string, returns the equivalent decimal value.

For example:

>>> from hexconvert import hex_convert

>>> hex_convert('6')
6

>>> hex_convert('1A')
26

>>> hex_convert('FFFF')
65535

We’ve provided a file, hexconvert, with a function, hex_convert:

hexconvert.py
def hex_convert(hex_in):
    """Convert a hexadecimal string, like '1A', into it's decimal equivalent."""

It is unimplemented. Finish it.