Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

Roy Smith roy at panix.com
Fri Nov 22 08:56:21 EST 2013


In article <mailman.3038.1385125611.18130.python-list at python.org>,
 Bharath Kummar <bathubharath94 at gmail.com> wrote:
 
> Could you please help me with my current research ?  Am implementing the
> concept in python language.
> My doubts are :

[Note to readers of American/British English; Indian English uses 
"doubt" the same way we would use "question"]

> 1)  Is it possible to Retrieve the address of a variable in python ?

No.  One of the fundamental concepts of Python is that it completely 
hides the physical memory.  Sure, at some point, when you write

x = 42

it allocates some piece of memory and puts the integer 42 into it, but 
all those details are hidden from you (and are implementation specific).


> 3)  Is it easy to find the Binary equivalence of a given Alphanumeric
> String ?

I think what you're talking about is the ord() function.  Given a single 
character (i.e. a string of length 1), it returns the unicode value for 
that character.  Thus:

>>> ord('X')
88

You could iterate over the characters in a string to find that for each 
one:

>>> [ord(c) for c in "My string"]
[77, 121, 32, 115, 116, 114, 105, 110, 103]


> 4)  Is it possible to count the number of 1's in the Binary equivalence ?

This is starting to sound like a homework problem, or possibly an 
interview question :-)



More information about the Python-list mailing list