On 2007-10-19, Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:
> "Arnaud Delobelle" wrote:
>
>> In binary 2 is 10. When you multiply by 10, you shift all your digits
>> left by 1 place.
>> When you multiply by 10**n (which is 1 followed by n zeroes), you
>> shift all your digits left by n places.
>
"Arnaud Delobelle" wrote:
> In binary 2 is 10. When you multiply by 10, you shift all your digits
> left by 1 place.
> When you multiply by 10**n (which is 1 followed by n zeroes), you
> shift all your digits left by n places.
I read somewhere:
Only 1 person in 1000 understands binary.
The oth
On 2007-10-19, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Oct 19, 1:44 am, MRAB <[EMAIL PROTECTED]> wrote:
>> On Oct 18, 7:05 am, Michele Simionato <[EMAIL PROTECTED]>
>>
>> if number == 0:
>> return "0"
>>
>
> Hey,
>
> Isn't
> if not number:
> return "0"
>
> faster?
Depends o
On Oct 19, 1:44 am, MRAB <[EMAIL PROTECTED]> wrote:
> On Oct 18, 7:05 am, Michele Simionato <[EMAIL PROTECTED]>
> wrote:> On Oct 17, 5:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
>
> > > def bin2dec(val):
> > > li = list(val)
> > > li.reverse()
> > > res = [int(li[x])*2**x for x in range(l
On Oct 18, 7:44 pm, MRAB <[EMAIL PROTECTED]> wrote:
> It returns '' when number == 0, so you need to test for that case:
>
> > def baseN(number, N=2):
> > """
> > >>> baseN(9, 2)
> > '1001'
> > """
> > assert 2 <= N <= 10
> > assert isinstance(number, int) and number >= 0
>
That was a very helpful answer Steven, thank you for taking the time
to write it!
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 18, 7:05 am, Michele Simionato <[EMAIL PROTECTED]>
wrote:
> On Oct 17, 5:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
>
> > def bin2dec(val):
> > li = list(val)
> > li.reverse()
> > res = [int(li[x])*2**x for x in range(len(li))]
> > print sum(res)
>
> > It basically does the sam
On Wed, 17 Oct 2007 23:06:24 -0700, Ixiaus wrote:
> I know '<<' is shifting x over by n bits; but could you point me to some
> literature that would explain why it is the same as "x*2**n"? (Googling
> only returns bit shift, but doesn't necessarily explain the manner in
> which you are using it)
On Oct 18, 7:06 am, Ixiaus <[EMAIL PROTECTED]> wrote:
[...]
> I know '<<' is shifting x over by n bits; but could you point me to
> some literature that would explain why it is the same as "x*2**n"?
I haven't got literature but I've got a (hopefully straightforward)
explanation:
In binary 2 is 10
Stargaming a écrit :
> On Wed, 17 Oct 2007 22:05:36 +0200, Bruno Desthuilliers wrote:
> [snip]
>> Note that there's also the reverse() function that returns a reverse
>> iterator over any sequence, so you could also do:
>>
>> li = list('allo')
>> print ''.join(reverse(li))
>>
>
> Note this certain
On Wed, 17 Oct 2007 22:05:36 +0200, Bruno Desthuilliers wrote:
[snip]
>
> Note that there's also the reverse() function that returns a reverse
> iterator over any sequence, so you could also do:
>
> li = list('allo')
> print ''.join(reverse(li))
>
Note this certainly should've been `reversed()`
> Right idea: now to remove all those intermediate lists you construct.
> 1. reversed(val) creates an iterator that runs over the elements (here
> of a string) in reverse order.
> 2. enumerate() is usually better than using an explicit list index.
> 3. You can use a generator in your sum to avoid c
On Oct 17, 5:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
> def bin2dec(val):
> li = list(val)
> li.reverse()
> res = [int(li[x])*2**x for x in range(len(li))]
> print sum(res)
>
> It basically does the same thing int(string, 2) does.
>
> Thank you for the responses!
BTW, here is the
On Oct 17, 6:23 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
> On Oct 17, 10:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thank you for the quick responses.
>
> > I did not know that about integer literals beginning with a '0', so
> > thank you for the explanation. I never really use PHP except
Ixiaus wrote:
> I have recently (today) just started learning/playing with Python. So
> far I am excited and impressed (coming from PHP background).
>
> I have a few questions regarding Python behavior...
>
> val = 'string'
> li = list(val)
> print li.reverse()
>
> returns nothing, but,
>
> va
On Oct 17, 4:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
> Thank you for the quick responses.
>
> I did not know that about integer literals beginning with a '0', so
> thank you for the explanation. I never really use PHP except for
> handling basic forms and silly web stuff, this is why I picked up
>
On Oct 17, 10:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
> Thank you for the quick responses.
>
> I did not know that about integer literals beginning with a '0', so
> thank you for the explanation. I never really use PHP except for
> handling basic forms and silly web stuff, this is why I picked up
Thank you for the quick responses.
I did not know that about integer literals beginning with a '0', so
thank you for the explanation. I never really use PHP except for
handling basic forms and silly web stuff, this is why I picked up
Python because I want to teach myself a more powerful and broad
Ixiaus wrote:
> val = 'string'
> li = list(val)
> print li.reverse()
>
> returns nothing, but,
Yes -- li.reverse() returns None. "print None" prints nothing.
> val = 'string'
> li = list(val)
> li.reverse()
> print li
>
> returns what I want.
I'm afraid not. li.reverse() still returns None,
On 2007-10-17, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Ixiaus a écrit :
>> val = 00110
>>
>> as the integer 72 instead of returning 00110, why does Python
>> do that?
>
> Literal integers starting with '0' (zero) are treated as octal.
> It's a pretty common convention (like 0x for hexa).
On Oct 17, 8:37 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
> I have a few questions regarding Python behavior...
> as the integer 72 instead of returning 00110, why does Python do that?
> (and how can I get around it?)
You can do this:
def bin(x):
return int(x, 2)
val = bin('00110')
--
Paul Hank
Ixiaus a écrit :
> I have recently (today) just started learning/playing with Python. So
> far I am excited and impressed
Welcome onboard then !-)
> (coming from PHP background).
>
> I have a few questions regarding Python behavior...
>
> val = 'string'
> li = list(val)
> print li.reverse()
>
On Oct 17, 3:37 pm, Ixiaus <[EMAIL PROTECTED]> wrote:
> I have recently (today) just started learning/playing with Python. So
> far I am excited and impressed (coming from PHP background).
>
> I have a few questions regarding Python behavior...
>
> val = 'string'
> li = list(val)
> print li.reverse
li.reverse() does not return a list it just changes the list li.
val = 00110 is evaluated in base 8 try without leading 0s
On 10/17/07, Ixiaus <[EMAIL PROTECTED]> wrote:
>
> I have recently (today) just started learning/playing with Python. So
> far I am excited and impressed (coming from PHP b
On 2007-10-17, Ixiaus <[EMAIL PROTECTED]> wrote:
> val = 'string'
> li = list(val)
> print li.reverse()
>
> returns nothing, but,
>
> val = 'string'
> li = list(val)
> li.reverse()
> print li
>
> returns what I want. Why does Python do that?
Because it does. :)
> Also I have been playing around
I have recently (today) just started learning/playing with Python. So
far I am excited and impressed (coming from PHP background).
I have a few questions regarding Python behavior...
val = 'string'
li = list(val)
print li.reverse()
returns nothing, but,
val = 'string'
li = list(val)
li.reverse(
I have recently (today) just started learning/playing with Python. So
far I am excited and impressed (coming from PHP background).
I have a few questions regarding Python behavior...
val = 'string'
li = list(val)
print li.reverse()
returns nothing, but,
val = 'string'
li = list(val)
li.reverse(
T.Crane wrote:
> I'm new to python and I seem to get different behavior depending on...
> well who knows what. Here's my question concerning importation of
> packages/modules.
>
> I want to use scipy. So at the prompt (using iPython, installed with
> Enthought edition on Windows XP) I type:
>
>
T.Crane wrote:
> I'm new to python and I seem to get different behavior depending on...
> well who knows what. Here's my question concerning importation of
> packages/modules.
>
> I want to use scipy. So at the prompt (using iPython, installed with
> Enthought edition on Windows XP) I type:
>
>
I'm new to python and I seem to get different behavior depending on...
well who knows what. Here's my question concerning importation of
packages/modules.
I want to use scipy. So at the prompt (using iPython, installed with
Enthought edition on Windows XP) I type:
ln [1]: from scipy import *
N
Roberto Bonvallet wrote:
> Omar wrote:
> > more to come!
>
> Please, use a more meaningful subject next time, like "Integration of
> Python and Flash" or "Where can I find vido tutorials". That way it will
> be easier to people that knows about the subject to find your message and
> answer you.
>
thank you all for your replies
--
http://mail.python.org/mailman/listinfo/python-list
Omar wrote:
> more to come!
Please, use a more meaningful subject next time, like "Integration of
Python and Flash" or "Where can I find vido tutorials". That way it will
be easier to people that knows about the subject to find your message and
answer you.
And please think of us, non-native Engl
> 1) I'm also learning to program flash movies while I learn to do
> python. How can one implement flash movies into their python code?
Depending on what "implementing flash movies into Python code" means.
Python and Flash can be complementary. You can develop the UI in Flash
and have it talk to
Omar schrieb:
> 1) I'm also learning to program flash movies while I learn to do
> python. How can one implement flash movies into their python code?
You can't - flash uses action script, a variant of ECMA script. There is
a PyPy-javascript-backend available, but I guess that's a little bit
bey
Hi all...this is a good group so I'm sure you'll tolerate some more
noobish questions...
1) I'm also learning to program flash movies while I learn to do
python. How can one implement flash movies into their python code?
2) besides Chieh's tutorials on the python.org site, anyone know of any
oth
Steve Holden <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> administrata wrote:
>
> > Hi! I'm programming maths programs.
> > And I got some questions about mathematical signs.
> >
> > 1. Inputing suqare like a * a, It's too long when I do time-consuming
> >things. Can it
In article <[EMAIL PROTECTED]>,
Steve Holden <[EMAIL PROTECTED]> wrote:
> > 2. Inputing fractions like (a / b) + (c / d), It's tiring work too.
> >Can it be simplified?
Can't this just be written as a/b+c/d ? How much simpler can it get?
I would think you need at least one symbol per op
administrata wrote:
Hi! I'm programming maths programs.
And I got some questions about mathematical signs.
1. Inputing suqare like a * a, It's too long when I do time-consuming
things. Can it be simplified?
You mean you have to write a*a*a*a when you want the fourth power? You
need the exponent
On Sun, Feb 06, 2005 at 12:26:30PM -0800, administrata wrote:
> Hi! I'm programming maths programs.
> And I got some questions about mathematical signs.
>
> 1. Inputing suqare like a * a, It's too long when I do time-consuming
>things. Can it be simplified?
You can write powers with the "**"
Hi! I'm programming maths programs.
And I got some questions about mathematical signs.
1. Inputing suqare like a * a, It's too long when I do time-consuming
things. Can it be simplified?
2. Inputing fractions like (a / b) + (c / d), It's tiring work too.
Can it be simplified?
3. How can i
41 matches
Mail list logo