How to use the pyromaths.outils.Arithmetique.valeur_alea function in pyromaths

To help you get started, we’ve selected a few pyromaths examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def valeurs_quotient_frac():  # cree 4 fractions et un tuple de signes (+,+)
    while True:
        (n1, d1) = (valeur_alea(-10, 10), valeur_alea(2, 10))
        lepgcd = pgcd(n1, d1)
        if lepgcd != n1 and lepgcd != d1:
            break
    (n1, d1) = (n1 // lepgcd, d1 // lepgcd)
    while True:
        (n3, d3) = (valeur_alea(-10, 10), valeur_alea(2, 10))
        lepgcd = pgcd(n3, d3)
        if lepgcd != n3 and lepgcd != d3:
            break
    (n3, d3) = (n3 // lepgcd, d3 // lepgcd)
    (n2, n4) = (valeur_alea(1, 10), valeur_alea(1, 10))
    if randrange(2) == 0:
        s1 = '+'
    else:
        s1 = '-'
    if randrange(2) == 0:
        s2 = '+'
    else:
        s2 = '-'
    return ((n1, d1), (n2, 1), (n3, d3), (n4, 1), (s1, s2))
github Pyromaths / pyromaths / src / pyromaths / ex / sixiemes / operations.py View on Github external
def valeurs():
    nba = Arithmetique.valeur_alea(111, 99999)
    while 1:
        nbb = Arithmetique.valeur_alea(111, 99999)
        if nbb - (nbb // 10) * 10:
            break
    puisb = Arithmetique.valeur_alea(-2, 0)
    nbb = nbb * 10 ** puisb
    deca = [str(nba)[i] for i in range(len(str(nba)))]
    decb = [str(nbb)[i] for i in range(len(str(nbb)))]
    if random.randrange(2):
        (nba, deca, nbb, decb) = (nbb, decb, nba, deca)
    if deca.count('.'):
        posa = deca.index('.')
    else:
        posa = len(deca)
    if decb.count('.'):
        posb = decb.index('.')
    else:
        posb = len(decb)
github Pyromaths / pyromaths / src / pyromaths / ex / sixiemes / operations.py View on Github external
def valeurs():
    nba = Arithmetique.valeur_alea(111, 99999)
    while 1:
        nbb = Arithmetique.valeur_alea(111, 99999)
        if nbb - (nbb // 10) * 10:
            break
    puisb = Arithmetique.valeur_alea(-2, 0)
    nbb = nbb * 10 ** puisb
    deca = [str(nba)[i] for i in range(len(str(nba)))]
    decb = [str(nbb)[i] for i in range(len(str(nbb)))]
    if random.randrange(2):
        (nba, deca, nbb, decb) = (nbb, decb, nba, deca)
    if deca.count('.'):
        posa = deca.index('.')
    else:
        posa = len(deca)
    if decb.count('.'):
        posb = decb.index('.')
    else:
        posb = len(decb)

    lavtvirg = max(posa, posb)
    laprvirg = max(len(deca) - posa, len(decb) - posb)
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / equations.py View on Github external
def valeurs(pyromax):  # crée les valeurs aléatoires pour l'équation
    while True:
        coefs = [Arithmetique.valeur_alea(-pyromax, pyromax) for i in range(6)]
        sgn = Arithmetique.valeur_alea(-1, 1)
        if sgn > 0:
            signe = "+"
        else:
            signe = "-"
        while True:
            while True:
                dens = [Arithmetique.valeur_alea(2, 9) for i in range(3)]
                if dens[0] != dens[1] and dens[0] != dens[2] and dens[1] != \
                    dens[2]:
                    break
            ppcm = Arithmetique.ppcm(dens[0], Arithmetique.ppcm(dens[1], dens[2]))
            densprim = [ppcm // dens[i] for i in range(3)]
            if densprim[0] < 10 and densprim[1] < 10 and densprim[2] < \
                10:
                break

        nvxcoefs = [coefs[i] * densprim[i // 2] for i in range(6)]
        if (nvxcoefs[0] + nvxcoefs[2] * sgn) - nvxcoefs[4] != 0:
            break
    return (tuple(coefs), tuple(dens), tuple(densprim), (signe, sgn),
            tuple(nvxcoefs))
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / puissances.py View on Github external
n2 != 1 and n3 != 1:
            break
    (e1, e2, e3, e4) = (valeur_alea(-10, 10), valeur_alea(-10, 10),
                        valeur_alea(2, 10), valeur_alea(2, 5))
    a = verifie_type((n1, n2, n3, e1, e2, e3, e4))
    while True:
        (b1, b2) = (valeur_alea(2, max), valeur_alea(2, max))
        (b1, b2) = (b1 / pgcd(b1, b2), b2 / pgcd(b1, b2))
        if b1 != 1 and b2 != 1:
            break
    (n1, n2) = ((b1 * valeur_alea(2, max)) * 10 ** randrange(-emax, emax +
                1), (b2 * valeur_alea(2, max)) * 10 ** randrange(-emax,
                emax + 1))
    n3 = ((b1 * b2) * choice((1, 2, 4, 5, 8))) * 10 ** randrange(-emax,
            emax + 1)
    (e1, e2, e3, e4) = (valeur_alea(-10, 10), valeur_alea(-10, 10),
                        valeur_alea(-10, -2), valeur_alea(2, 5))
    b = verifie_type((n1, n2, n3, e1, e2, e3, e4))
    return (a, b)
github Pyromaths / pyromaths / src / pyromaths / ex / sixiemes / decimaux.py View on Github external
def valeurs_units():
    """
    renvoie les valeurs pour les conversions d'unités
    """

    a = Arithmetique.valeur_alea(101, 999)
    p = random.randrange(-2, 0)
    unit = random.randrange(3)
    if unit:
        # mètres ou grammes, on peut utiliser les k
        imax = 7
    else:
        # Litres, donc pas de kL
        imax = 6

    div0 = random.randrange(imax + p)

    while 1:
        div1 = random.randrange(imax)
        if div0 != div1:
            break
github Pyromaths / pyromaths / src / pyromaths / ex / quatriemes / puissances.py View on Github external
n2 != 1 and n3 != 1:
            break
    (e1, e2, e3, e4) = (valeur_alea(-10, 10), valeur_alea(-10, 10),
                        valeur_alea(2, 10), valeur_alea(2, 5))
    a = verifie_type((n1, n2, n3, e1, e2, e3, e4))
    while True:
        (b1, b2) = (valeur_alea(2, maxi), valeur_alea(2, maxi))
        (b1, b2) = (b1 / pgcd(b1, b2), b2 / pgcd(b1, b2))
        if b1 != 1 and b2 != 1:
            break
    (n1, n2) = ((b1 * valeur_alea(2, maxi)) * 10 ** randrange(-emax, emax + 
                1), (b2 * valeur_alea(2, maxi)) * 10 ** randrange(-emax,
                emax + 1))
    n3 = ((b1 * b2) * choice((1, 2, 4, 5, 8))) * 10 ** randrange(-emax,
            emax + 1)
    (e1, e2, e3, e4) = (valeur_alea(-10, 10), valeur_alea(-10, 10),
                        valeur_alea(-10, -2), valeur_alea(2, 5))
    b = verifie_type((n1, n2, n3, e1, e2, e3, e4))
    return (a, b)
github Pyromaths / pyromaths / src / pyromaths / ex / cinquiemes / relatifs.py View on Github external
def plus(pyromax):
    (a, b) = (Arithmetique.valeur_alea(-pyromax, pyromax), Arithmetique.valeur_alea(-pyromax,
              pyromax))
    return (a, b)
github Pyromaths / pyromaths / src / pyromaths / ex / quatriemes / developpements.py View on Github external
def def_vals4():
    expr = []
    for i in range(9):
        a = valeur_alea(-10, 10)
        e = randrange(3)
        if i % 3 == 0:
            expr.append([a, 'x', e])
            expr.append(' \,(')
        elif i % 3 == 1:
            expr.append([a, 'x', e])
        else:
            while e == expr[-1][2]:
                e = randrange(3)
            expr.append([a, 'x', e])
            expr.append(') ')
    return expr