[sage-edu] Re: unexpected int division

2011-11-12 Thread dimpase
This is more a pedagogical issue. When I'm teaching a maths class with some programming, I am always stressing that one of particular things to be learned is some programming, and this is potentially very useful, perhaps more useful than the particular maths concepts I cover. (Given that the ma

[sage-edu] Re: unexpected int division

2011-10-30 Thread john_perry_usm
William On Oct 30, 5:26 pm, William Stein wrote: > // is in Python 2.x for integer quotient. Ouch. I misread a webpage, badly. I guess this quote from the Python website answers the original question: "Because of severe backwards compatibility issues, not to mention a major flamewar on c.l.py,

Re: [sage-edu] Re: unexpected int division

2011-10-30 Thread William Stein
On Sun, Oct 30, 2011 at 11:15 AM, john_perry_usm wrote: > On Oct 29, 10:09 am, michel paul wrote: >> Here's a relatively minor issue that might not be minor for someone new to >> Sage. >> >> In illustrating very simple probability as len(outcomes)/len(sample_space), >> integer division occurs, so

Re: [sage-edu] Re: unexpected int division

2011-10-30 Thread Luiz Felipe Martins
Could there be a function slen() that retuns a Sage integer (analogous to srange())? Or you can simply define it in your own worksheet: def slen(lst): return Integer(len(lst)) On Sun, Oct 30, 2011 at 12:53 AM, Jason Grout wrote: > On 10/29/11 10:24 PM, kcrisman wrote: >> >> >> On Oct 29, 10

[sage-edu] Re: unexpected int division

2011-10-30 Thread john_perry_usm
On Oct 29, 10:09 am, michel paul wrote: > Here's a relatively minor issue that might not be minor for someone new to > Sage. > > In illustrating very simple probability as len(outcomes)/len(sample_space), > integer division occurs, so the probability becomes 0. The origin of this behavior is that

Re: [sage-edu] Re: unexpected int division

2011-10-29 Thread Jason Grout
On 10/29/11 10:24 PM, kcrisman wrote: On Oct 29, 10:40 pm, Jason Grout wrote: On 10/29/11 10:35 AM, David Joyner wrote: I would suggest that this "feature" in Python, was "fixed" in Python 3.0. Sage has not yet upgraded to 3.0. Luckily, Python includes a time machine to import things from

[sage-edu] Re: unexpected int division

2011-10-29 Thread kcrisman
On Oct 29, 10:40 pm, Jason Grout wrote: > On 10/29/11 10:35 AM, David Joyner wrote: > > > I would suggest that this "feature" in Python, was "fixed" in Python 3.0. > > Sage has not yet upgraded to 3.0. > > Luckily, Python includes a time machine to import things from the future ;) > > sage: from

[sage-edu] Re: unexpected int division

2011-10-29 Thread kcrisman
> > Sure - typical simple intro - throwing two dice: > > > S = [(die1, die2) for die1 in [1..6] for die2 in [1..6]] > > E = [throw for throw in S if sum(throw) == 7] > > > len(E)/len(S) will produce 0.  We can very easily use 1.0*len(E)/len(S), or > > we can use Integer(len(E))/len(S).  I prefer t