> > 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 the latter.  Either way, a
> > student response will be, "Why do we have to do that here?"
>
> I see what you mean:
>
> sage: S = [(die1, die2) for die1 in [1..6] for die2 in [1..6]]
> sage: E = [throw for throw in S if sum(throw) == 7]
> sage: len(E); len(S); len(E)/len(S); (1*len(E))/(1*len(S))
> 6
> 36
> 0
> 1/6

This is a great question for sage-edu.  Do others have thoughts on
this?  I'm really curious.

Notice that using Python `set`s doesn't help, and even using Sage
`Set`s doesn't help!

sage: S1 = Set(S)
sage: type(S1)
<class 'sage.sets.set.Set_object_enumerated_with_category'>
sage: S1.cardinality()
36
sage: type(S1.cardinality())
<type 'int'>

At least *this* is a bug, I think.  I feel like a Sage method on a
Sage object should return Sage objects as much as possible.

> I would suggest that this "feature" in Python, was "fixed" in Python 3.0.
> Sage has not yet upgraded to 3.0.

And given that we haven't been able to even get to 2.7 yet, won't for
quite some time, most likely.

- kcrisman

-- 
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en.

Reply via email to