How to use pyromaths - 10 common examples

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.

Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github
``````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))``````
Pyromaths / pyromaths / src / pyromaths / ex / sixiemes / operations.py View on Github
``````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)``````
Pyromaths / pyromaths / src / pyromaths / ex / sixiemes / operations.py View on Github
``````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)``````
Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / equations.py View on Github
``````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))``````
Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github
``````def valeurs_somme_prod():  #cree 3 fractions et un tuple de signes (+,*)
while True:
(base1, base2) = (valeur_alea(-13, 13), valeur_alea(-13, 13))
lepgcd = pgcd(base1, base2)
(base1, base2) = (base1 // lepgcd, base2 // lepgcd)
if base1 != 1 and base2 != 1:
break
(n2, d2) = (base1 * valeur_alea(-10, 10), abs(base2 * valeur_alea(2,
10)))
lepgcd = pgcd(n2, d2)
(n2, d2) = (n2 // lepgcd, d2 // lepgcd)
(n3, d3) = (base2 * valeur_alea(-10, 10), abs(base1 * valeur_alea(2,
10)))
lepgcd = pgcd(n3, d3)
(n3, d3) = (n3 // lepgcd, d3 // lepgcd)
(n1, d1) = (base1 * valeur_alea(-10, 10), abs(pgcd(d2, base2 *
valeur_alea(2, 10))))
lepgcd = pgcd(n1, d1)
(n1, d1) = (n1 // lepgcd, d1 // lepgcd)
if randrange(2) == 0:
s1 = '+'
else:
s1 = '-'
if randrange(2) == 0:
s2 = '*'
else:
s2 = ':'
if s2 == '*':
return ((n1, d1), (n2, d2), (n3, d3), (s1, s2))
else:``````
Pyromaths / pyromaths / src / pyromaths / ex / lycee / CercleTrigo.py View on Github
``````def simprad(liste):
"""Simplifie la fraction d'un angle en radians. Le paramètre est une liste d'entiers, pour représenter une fraction."""
p = pgcd(liste[0],liste[1])
return [f // p for f in liste]``````
Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github
``````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 = '+'``````
Pyromaths / pyromaths / src / pyromaths / ex / lycee / Derivation.py View on Github
``````def InitPoints(minimum=-6.1, maximum=6.1, nbval=3):
dY = []
directions = [(-1) ** i for i in range(nbval - 1)]
directions.append(0)
shuffle(directions)
for i in range((nbval - 1) // 2):
while True:
a, b = randrange(1, 5), randrange(1, 5)
if pgcd(a, b) == 1 and a % b != 0:
dY.append(Fraction(a, b))
break
for i in range(nbval - 1 - len(dY)):
dY.append(randrange(1, 5))
shuffle(dY)
for i in range(nbval):
if directions[i] == 0:
dY.insert(i, 0)
else:
dY[i] = dY[i] * directions[i]
dY.insert(0, 0)
dY.append(0)
redo = True
while redo:
lX = [int(minimum) + 1 + int(1.*i * (maximum - minimum - 2) / nbval) + randrange(4) for i in range(nbval)]
for i in range(len(lX) - 1):
if lX[i + 1:].count(lX[i]):``````
Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / equations.py View on Github
``````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))``````
Pyromaths / pyromaths / src / pyromaths / ex / sixiemes / operations.py View on Github
``````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('.')``````

pyromaths

Create maths exercises in LaTeX and PDF format

GPL-3.0