[Tutor] hexodecimal to decimal form

Alan Gauld alan.gauld at btinternet.com
Tue Nov 11 18:15:22 CET 2014

On 11/11/14 09:00, William Becerra wrote:

>  >>print blank
> <__main__.point instance at 0x02B38E40>
> the author says the the < 0x02B38E40> is in hexadecimal form

Correct that's what the 0x at the front signifies.

> heres is my question:
> How can i convert from hexodecimal form to decimal form?

You can use the int() type converter:

 >>> int(0x16)
 >>> int(0x02B38E40)

But there is little point since the hex number is a
memory address that means nothing to you as a programmer
since you can't change it, or do anything useful with it.

> basically what i want is to use the attributes blank.x and blank.y as a
> single point like in  the mathematics format (x, y) co-ordinates so that
> i can workout distance

You can do that without any use of hex.
Just use blank.x and blank.y like any other variable.

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list