Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tex_answer(self):
exo = [r'\exercice*']
exo.append(_(u'Déterminer les racines des polynômes :\\par'))
noms = [r'P\,(x) &= ', r'Q\,(x) &= ', r'R\,(x) &= ']
r = ''
question = [[], [], []]
for i in range(3):
p = []
m = Polynome(list(self.exercice[i])).ordonne()
if factoriser('%r' % Polynome(m)):
p = [factoriser('%r' % Polynome(m))]
while factoriser(p[-1]):
p.append(factoriser(p[-1]))
if p and eval(Priorites3.splitting(p[-1])[0]).degre() > 0:
tmp = Priorites3.texify([Priorites3.splitting(p[j]) for j in range(len(p))])
question[i].append('{$\\! \\begin{aligned}')
question[i].append(noms[i] + str(Polynome(m, 'x')) + r'\\')
question[i].append('\\\\\n'.join(['&=%s' % (tmp[j]) for j in range(len(tmp))]))
question[i].append(r'\end{aligned}$}\par')
lp = Priorites3.splitting(p[-1])
racines = []
for e in lp:
if e[:9] == 'Polynome(':
e = eval(e)
if len(e) == 2:
racines.append(str(Fraction(-e[1][0], e[0][0]).simplifie()))
else:
racines.append('0')
if len(racines) > 1:
question[i].append(_(u'\\underline{Les racines de $%s$ sont }\\fbox{$%s$}') % (noms[i].rstrip(r' &= '), '$}\\underline{ et }\\fbox{$'.join(racines)))
elif len(racines) == 1:
ft( -3\\right) -2=\\dfrac{4\\times \\cancel{3}\\times -1}{\\cancel{3}\\times 1}-
2=-4-2=-6', '\\psdot [dotsize=4.5pt,dotstyle=x](0, -2)', '\\psdot [dotsize=4.5pt
,dotstyle=x](-3, -6.0)']
:rtype: list of string
"""
u = coefdir(A, B)
if isinstance(u, int) or u.d == 1:
x1 = decimaux(B[0])
else:
B = (u.d, u.n + float(A[1]))
if not dansrep(B, xmin, xmax, ymin, ymax):
B = (-u.d, -u.n + float(A[1]))
x1 = decimaux(str(B[0]))
l = Priorites3.texify([Polynome([[u, 1], [A[1], 0]], "x")(B[0])])
l.extend(Priorites3.texify(Priorites3.priorites(Polynome([[u, 1], [A[1], 0]], "x")(B[0]))))
l = [u'Tracer la droite représentative ($d_' + str(i) + '$) de la fonction $' + f + ':x\\longmapsto ' + str(Polynome([[u, 1], [A[1], 0]], "x")) + '$.',
'On sait que $' + f + '(0)=' + decimaux(str(A[1])) + '$ et $' + f + '(' + x1 + ')=' + "=".join(l) + "$.",
'\\psdot [dotsize=4.5pt,dotstyle=x]' + str(A),
'\\psdot [dotsize=4.5pt,dotstyle=x]' + str(B),
]
return l
shuffle(exo)
lexo.append(exo[0](l[13:17], diff=diff.pop()))
lexo.append(exo[1](l[17:21], diff=diff.pop()))
exo = ["\\exercice", u"Factoriser chacune des expressions littérales suivantes :"]
exo.append("\\begin{multicols}{2}")
cor = ["\\exercice*", u"Factoriser chacune des expressions littérales suivantes :"]
cor.append("\\begin{multicols}{2}")
for i in range(len(lexo)):
p = [lexo[i]]
while True:
fact = factoriser(p[-1])
if fact:
p.append(fact)
else: break
p = Priorites3.texify([Priorites3.splitting(p[j]) for j in range(len(p))])
cor.append('\\\\\n'.join(['$%s=%s$' % (chr(i + 65), p[j]) for j in range(len(p) - 1)]))
cor.append('\\\\')
cor.append('\\fbox{$%s=%s$}\\\\\n' % (chr(i + 65), p[-1]))
exo.append('\\\\\n'.join(['$%s=%s$' % (chr(i + 65), Priorites3.texify([Priorites3.splitting(lexo[i])])[0]) for i in range(len(lexo))]))
exo.append("\\end{multicols}")
cor.append("\\end{multicols}")
return exo, cor