Hi there. I've got a strange behavior on a very simple case. This is just a little code that generates two rationals (a priori) and ask to return their product and display it as a rational. I put that in a loop and got strange results however only time to time. it doesn't look to me that it's deterministic. Who can help understanding and why not how to do it properly. Thanks
for i in range(100):
n1=randint(0,6)
d1=randint(1,4)
n2=randint(1,100)
d2=randint(1,100)
exp1 = str(n1)+"/"+str(d1)+"*"+str(n2)+"/"+str(d2) + " = "
exp2 = eval("Rational(" + str(n1)+"/"+str(d1)+"*"+str(n2)+"/"+str(d2) +")")
print(exp1 + str(exp2))
ps: looks like the indentation is lost when I copy the code.