The April Fools joke was on those of us who never received/have yet to
receive @Stefan's OP.
On 2/04/24 08:02, Avi Gross via Python-list wrote:
Is this a April 1 post for fools.
Multiplication with an asterisk symbol is built into python.
The same symbol used in other contexts has other con
Is this a April 1 post for fools.
Multiplication with an asterisk symbol is built into python.
The same symbol used in other contexts has other contexts has an assortment
of largely unrelated meanings such as meaning everything when used to
import.
On Mon, Apr 1, 2024, 1:27 PM Piergiorgio Sarto
On 2024-04-01 12:35, Joel Goldstick via Python-list wrote:
On Mon, Apr 1, 2024 at 1:26 PM Piergiorgio Sartor via Python-list
^^^
from math import *
a = 2
b = 3
print( a * b )
I guess the operator "*" can be imported from any module... :-)
No import is necessary.
Of cour
On Mon, Apr 1, 2024 at 1:26 PM Piergiorgio Sartor via Python-list
wrote:
>
> On 01/04/2024 10.40, Stefan Ram wrote:
> > Q: How can I multiply two variables in Python? I tried:
> >
> > a = 2
> > b = 3
> > print( ab )
> >
> > but it did not work.
> >
> > A: No, this cannot work. To mu
On 01/04/2024 10.40, Stefan Ram wrote:
Q: How can I multiply two variables in Python? I tried:
a = 2
b = 3
print( ab )
but it did not work.
A: No, this cannot work. To multiply, you need the multiplication
operator. You can import the multiplication operator from "mat
Steven D'Aprano :
> But by this time, we had already learned in secondary school that you can
> use any of the following to write multiplication:
>
> x × y
Not where I lived. (Those x's would have been a nightmare for the
teacher who had to mark people's test answers.)
> x ⋅ y
Yes. After all, i
In a message of Thu, 26 Nov 2015 05:09:13 +1100, "Steven D'Aprano" writes:
>On Thu, 26 Nov 2015 02:59 am, Laura Creighton wrote:
>
>> The great sticking point for the children I am teaching is
>> '*' means multiplication. You can really see that some people
>> have to make extensive mental modific
On Wed, Sep 28, 2011 at 4:28 PM, Tim Roberts wrote:
> My guess is that you actually typed
> p=3*a
> instead of
> p=2*a
>
> That produces 45.
>
Or alternatively, that you used an interactive Python environment and
didn't clear i between runs.
ChrisA
--
http://mail.python.org/mailman/listin
sakthi wrote:
>In the following code,
l=[1,2,3,4,5]
i=0
for a in l:
>... p=2*a
>... t=p+i
>... i=t
>...
t
>45
>
>Python gives an answer as 45. But i am getting 30 when i execute
>manually. Is there any different multiplication pattern in python?
My guess is that y
On 9/27/2011 12:50 PM, sakthi said this:
> On Sep 27, 1:43 pm, Chris Rebert wrote:
>> On Tue, Sep 27, 2011 at 10:21 AM, sakthi wrote:
>>> In the following code,
>> l=[1,2,3,4,5]
>> i=0
>> for a in l:
>>> ... p=2*a
>>> ... t=p+i
>>> ... i=t
>>> ...
>> t
>>> 45
>>
>>> Py
I think you may be doing something wrong.
If I run:
>>> l = [1, 2, 3, 4, 5]
>>> i = 0
>>> for a in l:
...i += 2 * a
...
>>> i
30
The result is 30 as expected.
Nowhere near the 155 that you are getting. :/
Again, could you state which version of python are you using (and what
OS) so
In my python 3.2, no problem:
>>> l=[1,2,3,4,5]
>>> i=0
>>> for a in l:
... p=2*a
... t=p+i
... i=t
... print("p={}, t={}, i={}".format(p,t,i))
...
p=2, t=2, i=2
p=4, t=6, i=6
p=6, t=12, i=12
p=8, t=20, i=20
p=10, t=30, i=30
>>> t
30
>>>
paz e amor (love and peace),
Alysson Bruno
Palmas(
On Sep 27, 1:43 pm, Chris Rebert wrote:
> On Tue, Sep 27, 2011 at 10:21 AM, sakthi wrote:
> > In the following code,
> l=[1,2,3,4,5]
> i=0
> for a in l:
> > ... p=2*a
> > ... t=p+i
> > ... i=t
> > ...
> t
> > 45
>
> > Python gives an answer as 45. But i am getting
On 09/27/2011 10:21 AM, sakthi wrote:
In the following code,
l=[1,2,3,4,5]
i=0
for a in l:
... p=2*a
... t=p+i
... i=t
...
t
45
Python gives an answer as 45. But i am getting 30 when i execute
manually. Is there any different multiplication pattern in python?
Thank yu.
I think
I tried running your code in ipython:
In [1]: l = [1,2,3,4,5]
In [2]: i = 0
In [3]: for a in l:
...: p = 2 * a
...: t = p + i
...: i = t
...:
In [4]:
In [4]: t
Out[4]: 30
The output from Python was 30, not 45. What Python version are you
running?
On Sep 27, 6:21 pm, sakth
On Sep 27, 1:21 pm, sakthi wrote:
> In the following code,>>> l=[1,2,3,4,5]
> >>> i=0
> >>> for a in l:
>
> ... p=2*a
> ... t=p+i
> ... i=t
> ...>>> t
>
> 45
>
> Python gives an answer as 45. But i am getting 30 when i execute
> manually. Is there any different multiplication pattern i
On Tue, Sep 27, 2011 at 10:21 AM, sakthi wrote:
> In the following code,
l=[1,2,3,4,5]
i=0
for a in l:
> ... p=2*a
> ... t=p+i
> ... i=t
> ...
t
> 45
>
> Python gives an answer as 45. But i am getting 30 when i execute
> manually. Is there any different multiplicati
On Mar 8, 12:04 pm, [EMAIL PROTECTED] wrote:
> On Mar 5, 2:16 am, Bruno Desthuilliers
> [EMAIL PROTECTED]> wrote:
> > [EMAIL PROTECTED] a écrit :
> > (snip)
>
> > > That reminds me: Is there a generic 'relation' pattern/recipie, such
> > > as finding a computer that's "paired" with multiple users
On Mar 5, 2:16 am, Bruno Desthuilliers wrote:
> [EMAIL PROTECTED] a écrit :
> (snip)
>
> > That reminds me: Is there a generic 'relation' pattern/recipie, such
> > as finding a computer that's "paired" with multiple users, each of who
> > are "paired" with multiple computers, without maintaining
[EMAIL PROTECTED] a écrit :
(snip)
>
> That reminds me: Is there a generic 'relation' pattern/recipie, such
> as finding a computer that's "paired" with multiple users, each of who
> are "paired" with multiple computers, without maintaining dual-
> associativity?
>
Yes : use a relational databas
On Mar 4, 9:46 pm, Jason Galyon <[EMAIL PROTECTED]> wrote:
> Gabriel Genellina wrote:
> > En Tue, 04 Mar 2008 23:50:49 -0200, Jason <[EMAIL PROTECTED]> escribió:
>
> >> How could I return a list or tuple of each unique combination of a given
> >> set of lists (perhaps from a dict or a list). This
Gabriel Genellina wrote:
> En Tue, 04 Mar 2008 23:50:49 -0200, Jason <[EMAIL PROTECTED]> escribió:
>
>> How could I return a list or tuple of each unique combination of a given
>> set of lists (perhaps from a dict or a list). This means the number of
>> lists are not known nor is the length of ea
En Tue, 04 Mar 2008 23:50:49 -0200, Jason <[EMAIL PROTECTED]> escribió:
> How could I return a list or tuple of each unique combination of a given
> set of lists (perhaps from a dict or a list). This means the number of
> lists are not known nor is the length of each.
Use the Google interfase fo
"Paul McGuire" <[EMAIL PROTECTED]> wrote:
>
>Does Python's run-time do any optimization of multiplication
>operations, like it does for boolean short-cutting? That is, for a
>product a*b, is there any shortcutting of (potentially expensive)
>multiplication operations as in:
Integer multiplication
Atanas Banov wrote:
> Paul McGuire wrote:
>> Does Python's run-time do any optimization of multiplication
>> operations, like it does for boolean short-cutting? That is, for a
>> product a*b, is there any shortcutting of (potentially expensive)
>> multiplication operations
>
> no. and the reason
Paul McGuire wrote:
> Does Python's run-time do any optimization of multiplication
> operations, like it does for boolean short-cutting? That is, for a
> product a*b, is there any shortcutting of (potentially expensive)
> multiplication operations
no. and the reason is very simple: to the extent
On 18 Feb 2006 16:48:38 -0800, Paul McGuire <[EMAIL PROTECTED]> wrote:
>Does Python's run-time do any optimization of multiplication
>operations, like it does for boolean short-cutting?
Here's the beginning of int_mul from Objects/intobject.c:
static PyObject *
int_mul(PyObject *v, PyObje
[Paul McGuire]
> Does Python's run-time do any optimization of multiplication
> operations, like it does for boolean short-cutting?
Usually, it is safest (and typically true) to assume that Python
performs no optimizations. To go beyond making assumptions, it is easy
to run a few timings:
>>> fr
On Sat, 18 Feb 2006 16:48:38 -0800, Paul McGuire wrote:
> Does Python's run-time do any optimization of multiplication
> operations, like it does for boolean short-cutting?
Do you know that these shortcuts are optimizations, or are you just
assuming it takes less time to do the comparison than it
29 matches
Mail list logo