Hello,
I've just tried to produce randomized fractions. I've decided to use
randint but I've noticed a wierd behavior shown in the following code with
one output.

Best regards.
Christophe

===== PYTHON CODE =====

for i in range(1, 6):
    a_Num = (-1)^randint(1, 2)*randint(1, 20)
    a_Den = randint(1, 20)
    a = a_Num / a_Den

    Beta_Num = randint(-20, 20)
    Beta_Den = randint(1, 20)
    Beta = Beta_Num / Beta_Den

    Gamma_Num = randint(-20, 20)
    Gamma_Den = randint(1, 20)
    Gamma = Gamma_Num / Gamma_Den

    print '---'
    print(a_Num, a_Den, a)
    print(Beta_Num, Beta_Den, Beta)
    print(Gamma_Num, Gamma_Den, Gamma)

print ''
print '======'
print ''

for i in range(1, 6):
    a_Num = (-1)^randint(1, 2)*randint(1, 20)
    a_Den = randint(1, 20)
    a = a_Num / a_Den

    Beta_Num = (-1)^randint(1, 2)*randint(1, 20)
    Beta_Den = randint(1, 20)
    Beta = Beta_Num / Beta_Den

    Gamma_Num = (-1)^randint(1, 2)*randint(1, 20)
    Gamma_Den = randint(1, 20)
    Gamma = Gamma_Num / Gamma_Den

    print '---'
    print(a_Num, a_Den, a)
    print(Beta_Num, Beta_Den, Beta)
    print(Gamma_Num, Gamma_Den, Gamma)


===== SAGE OUTPUT =====



---
(18, 12, 3/2)
(0, 20, 0)
(5, 7, 0)
---
(-3, 4, -3/4)
(-5, 1, -5)
(-19, 7, -3)
---
(-8, 5, -8/5)
(4, 11, 0)
(-18, 16, -2)
---
(1, 19, 1/19)
(-17, 3, -6)
(2, 2, 1)
---
(2, 8, 1/4)
(-1, 2, -1)
(-13, 6, -3)

======

---
(18, 12, 3/2)
(14, 3, 14/3)
(-9, 11, -9/11)
---
(9, 13, 9/13)
(-6, 3, -2)
(-1, 14, -1/14)
---
(-16, 1, -16)
(6, 4, 3/2)
(4, 17, 4/17)
---
(13, 7, 13/7)
(-11, 14, -11/14)
(20, 10, 2)
---
(17, 10, 17/10)
(6, 19, 6/19)
(7, 13, 7/13)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to