[Tutor] hexodecimal to decimal form
wbecerra1 at gmail.com
Tue Nov 11 15:13:34 CET 2014
Thank you for your time
On 11 Nov 2014 15:02, "Dave Angel" <davea at davea.name> wrote:
> William Becerra <wbecerra1 at gmail.com> Wrote in message:
> > Hello, I'm new to programming using Python 2.7.8 and Windows 8 OSI'm
> reading How to Think Like a Computer Scientist - learning with pythonon
> chapter 12.2theres the following code: class Point: passblank =
> point()blank.x = 3.0blank.y = 4.0
> >>>print blank.x
> > 3.0>>print blank.y4.0
> >>>print blank<__main__.point instance at 0x02B38E40>
> > the author says the the < 0x02B38E40> is in hexadecimal form
> > heres is my question:How can i convert from hexodecimal form to decimal
> You don't care about that 0x02.. number, except to distinguish
> this object from another. And in code you'd do that with the 'is'
> That hex number happens to be an address in memory for one of the
> python implementations.
> > is there any source i can read on 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
> > thank you
> If you want a tuple of the coordinates, you could do (blank.x,
> blank.y) And if you need to do arithmetic, go right ahead.
> x, y = blank.x, blank.y
> dist_from_org = sqrt(x*x + y*y)
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor