On Tuesday, April 15, 2014 8:39:04 PM UTC-4, William wrote:
>
> On Tue, Apr 15, 2014 at 4:53 PM, Bassie <[email protected] <javascript:>>
> wrote:
> > I'm running a double for loop, and dividing one over the other.
> Sagecloud
> > converts these fractions to 0, just like python2, but isn't it exactly
> what
> > it's not supposed to do.
> > """
> > for d in range(1,8):
> > for n in range(1,d):
> > print n/d
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > etc.
> > """
>
> Sage only converts integer literals. You need to do
>
> for d in [1..7]:
> for n in [1..d-1]:
> print n/d
>
>
Just to make it clear, range(1,7) gives Python ints, while [1..7] gives
Sage Integers. srange ("Sage" range) would do the same thing. Have fun!
for d in srange(1,8):
for n in srange(1,d):
print n/d
http://sagecell.sagemath.org/?q=vynikr
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.