def valeurs_somme_positive(): """Travail sur les sommes de fractions en quatrième""" l = [] op = "+-"[random.randrange(2)] n2, d2 = random.randrange(1, 11), random.randrange(2, 11) if op == "-" and 1 - n2 / d2 > 0: l.append('1 %s Fraction(%s, %s)' % (op, n2, d2)) else: l.append('Fraction(%s, %s) %s 1' % (n2, d2, op)) op = "+-"[random.randrange(2)] n1 = random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) if op == "-" and n1 - n2 / d2 > 0: l.append('%s %s Fraction(%s, %s)' % (n1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s %s' % (n2, d2, op, n1)) op = "+-"[random.randrange(2)] n1 = random.randrange(1, 9) + random.randrange(1, 9) / 10. n2, d2 = random.randrange(1, 11), random.randrange(2, 11) if op == "-" and n1 - n2 / d2 > 0: l.append('%s %s Fraction(%s, %s)' % (n1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s %s' % (n2, d2, op, n1)) op = "+-"[random.randrange(2)] n1 = random.randrange(1, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) if op == "-" and n1 - n2 > 0: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n1, d2, op, n2, d2)) else: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n2, d2, op, n1, d2)) op = "+-"[random.randrange(2)] n1, d1 = random.randrange(1, 11), random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) * d1 if op == "-" and n1 / d1 - n2 / d2 > 0: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n1, d1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n2, d2, op, n1, d1)) for dummy in range(3): op = "+-"[random.randrange(2)] d1, d2 = 2, 2 lepgcd = Arithmetique.pgcd(d1, d2) while lepgcd == d1 or lepgcd == d2: n1, d1 = random.randrange(1, 11), random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) lepgcd = Arithmetique.pgcd(d1, d2) if op == "-" and n1 / d1 - n2 / d2 > 0: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n1, d1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n2, d2, op, n1, d1)) random.shuffle(l) return l
def valeurs_produit(): l = [] for dummy in range(4): n1 = d1 = n2 = d2 = a = b = 2 while Arithmetique.pgcd(a, b) > 1: a = random.randrange(1, 11) b = random.randrange(2, 11) while Arithmetique.pgcd(n1 * a, d1 * b) > 1: n1 = random.randrange(1, 11) d1 = random.randrange(2, 11) while Arithmetique.pgcd(n2 * b, d2 * a) > 1: n2 = random.randrange(1, 11) d2 = random.randrange(2, 11) l.append(_('Fraction(%s, %s)*Fraction(%s,%s)') % (n1 * a, d1 * b, n2 * b, d2 * a)) return l
def valeurs_produit(): l = [] for dummy in range(4): n1 = d1 = n2 = d2 = a = b = 2 while Arithmetique.pgcd(a, b) > 1: a = random.randrange(1, 11) b = random.randrange(2, 11) while Arithmetique.pgcd(n1 * a, d1 * b) > 1: n1 = random.randrange(1, 11) d1 = random.randrange(2, 11) while Arithmetique.pgcd(n2 * b, d2 * a) > 1: n2 = random.randrange(1, 11) d2 = random.randrange(2, 11) l.append( _('Fraction(%s, %s)*Fraction(%s,%s)') % (n1 * a, d1 * b, n2 * b, d2 * a)) return l
def valeurs_entier1(pyromax): # renvoie (coef0, coef1, coef2, carre0, carre1, carre2, b) a = carres[random.randrange(len(carres))] while True: v0 = random.randrange(2, pyromax) v1 = random.randrange(2, pyromax) b0 = random.randrange(2, pyromax) b1 = random.randrange(2, pyromax) a0 = (b1 * v0) * v1 a1 = v1 * b0 if b0 < b1 and Arithmetique.pgcd(a0, a1) != a1: break return (a0, b0, a1, b1, a)
def valeurs_aPbRc(pyromax): # renvoie (coef0, coef1, coef2, carre0, carre1, carre2, b) while True: a = carres[random.randrange(len(carres))] b = carres[random.randrange(len(carres))] if a != b and Arithmetique.pgcd(a, b) != min(a, b): break while True: c = random.randrange(2, pyromax) d = Arithmetique.valeur_alea(-pyromax, pyromax) if c != d: break return (c, a, d, b)
def valeurs_entier1( pyromax): # renvoie (coef0, coef1, coef2, carre0, carre1, carre2, b) a = carres[random.randrange(len(carres))] while True: v0 = random.randrange(2, pyromax) v1 = random.randrange(2, pyromax) b0 = random.randrange(2, pyromax) b1 = random.randrange(2, pyromax) a0 = (b1 * v0) * v1 a1 = v1 * b0 if b0 < b1 and Arithmetique.pgcd(a0, a1) != a1: break return (a0, b0, a1, b1, a)
def valeurs_aPbRc( pyromax): # renvoie (coef0, coef1, coef2, carre0, carre1, carre2, b) while True: a = carres[random.randrange(len(carres))] b = carres[random.randrange(len(carres))] if a != b and Arithmetique.pgcd(a, b) != min(a, b): break while True: c = random.randrange(2, pyromax) d = Arithmetique.valeur_alea(-pyromax, pyromax) if c != d: break return (c, a, d, b)