[Tutor] hexodecimal to decimal form
William Becerra
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
> form?
>
> 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'
> operator.
> 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.
> Like
>
> x, y = blank.x, blank.y
> dist_from_org = sqrt(x*x + y*y)
>
>
>
> --
> DaveA
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141111/c01c9945/attachment.html>
More information about the Tutor
mailing list