[Python-ideas] [Wild Idea] Static Ducks
Gerald Britton
gerald.britton at gmail.com
Wed Sep 23 15:25:45 CEST 2009
> > Ask a mathematician, and he'll say that they are the same. The
> > underlying concept of number treats 3 and 3.0 as the same thing (until
> > you get to some extremely hairy mathematics,
>
> No, even naive non-mathematicians may tell you they're different. If
> you ask any reasonably competent (but non-programmer) sixth grader,
> they will tell you that 3/2 is "1 with a remainder of 1" (and we have
> to play scissor-paper-stone to decide who gets the last piece of hard
> candy), while 3.0/2 is "1.5" (and we split the third piece of cake in
> half with a fork).
Naive non-mathematicians may indeed tell you that they are different,
but they are wrong. Hopefully most readers of this thread, if not
professional mathematicians per se, are not naive. I am neither naive
nor a mathematician by trade (though I have had healthy doses of maths
of all sorts), but if you ask me what three divided by two is, I'll
say one-and-a-half, every time, _unless_ you specify that the answer
must be an integer, in which case I would answer, "One!"
Ironically, since this is a Python list:
>>> 3/2
1.5
I have to be explicit to get integer division:
>>> 3//2
1
which is precisely my point
More information about the Python-ideas
mailing list