def main(parametre): question = "" exo = ["Effectuer sans calculatrice :", "\\begin{multicols}{3}\\noindent", " \\begin{enumerate}"] cor = ["Effectuer sans calculatrice :", "\\begin{multicols}{3}\\noindent", " \\begin{enumerate}"] modules = (plus, moins, ) modules_dec= (plus_dec, moins_dec, ) calculs = [i for i in range(20)] random.shuffle(calculs) for j in range(4): (a, b) = modules[calculs[j] // 10](10) choix_trou(a, tex_coef(b, '', bpn=1), a + b, '+', exo, cor) for j in range(4,14): (a, b) = modules[calculs[j] // 10](10) if calculs[j] // 10 == 0: choix_trou(a, tex_coef(b, '', bpn=1), a + b, '+', exo, cor) if calculs[j] // 10 == 1: choix_trou(a, tex_coef(b, '', bpn=1), a - b, '-', exo, cor) for j in range(14,20): (a, b) = modules_dec[calculs[j] // 10](10) if calculs[j] // 10 == 0: choix_trou(TeX(a), tex_coef(b, '', bpn=1), TeX(a + b), '+', exo, cor) if calculs[j] // 10 == 1: choix_trou(TeX(a), tex_coef(b, '', bpn=1), TeX(a - b), '-', exo, cor) exo.extend([" \\end{enumerate}", "\\end{multicols}"]) cor.extend([" \\end{enumerate}", "\\end{multicols}"]) return (exo, cor, question)
def main(parametre): question = "" exo = ["Effectuer sans calculatrice :", "\\begin{multicols}{3}\\noindent", " \\begin{enumerate}"] cor = ["Effectuer sans calculatrice :", "\\begin{multicols}{3}\\noindent", " \\begin{enumerate}"] modules = (plus, moins, plus, div) calculs = [i for i in range(20)] for i in range(20): j = random.randrange(0, len(calculs)) (a, b) = modules[calculs[j] // 5](10) if calculs[j] // 5 == 0: choix_trou(a, tex_coef(b, '', bpn=1), a + b, '+', exo, cor) if calculs[j] // 5 == 1: choix_trou(a, tex_coef(b, '', bpn=1), a - b, '-', exo, cor) if calculs[j] // 5 == 2: choix_trou(a, tex_coef(b, '', bpn=1), a * b, '\\times', exo, cor) if calculs[j] // 5 == 3: choix_trou(a, tex_coef(b, '', bpn=1), a // b, '\\div', exo, cor) calculs.pop(j) exo.extend([" \\end{enumerate}", "\\end{multicols}"]) cor.extend([" \\end{enumerate}", "\\end{multicols}"]) return (exo, cor, question)
def tex_proprietes_neg(parametre): question = "" exo = [u"Écrire sous la forme d'une puissance de 10 puis donner l'écriture", u" décimale de ces nombres :", "\\begin{multicols}{2}", " \\noindent%", " \\begin{enumerate}"] cor = [u"Écrire sous la forme d'une puissance de 10 puis donner l'écriture", u" décimale de ces nombres :", "\\begin{multicols}{2}", " \\noindent%", " \\begin{enumerate}"] lexos = [0, 1, 2, 3, 0, 1, 2, 3] #0: a^n*a^p ; 1: (a^n)^p ; 2:a^n/a^p for i in range(len(lexos)): lexp = [randrange(-6, 6) for i in range(2)] j = lexos.pop(randrange(len(lexos))) # FIXME : À finir if j == 0: while abs(lexp[0] + lexp[1]) > 10: lexp = [randrange(-6, 6) for i in range(2)] exo.append("\\item $10^{%s} \\times 10^{%s} = \\dotfill$" % tuple(lexp)) cor.append("\\item $10^{%s}\\times 10^{%s}=" % tuple(lexp)) cor.append("10^{%s+%s}=" % (lexp[0], tex_coef(lexp[1], '', bpn=1))) cor.append("10^{%s}=%s$" % (lexp[0] + lexp[1], decimaux(10 ** (lexp[0] + lexp[1]), 1))) elif j == 1: while abs(lexp[0] * lexp[1]) > 10: lexp = [randrange(-6, 6) for i in range(2)] exo.append("\\item $(10^{%s})^{%s}=\\dotfill$" % (lexp[0], lexp[1])) cor.append("\\item $(10^{%s})^{%s}=" % tuple(lexp)) cor.append("10^{%s \\times %s}=" % (lexp[0], tex_coef(lexp[1], '', bpn=1))) cor.append("10^{%s}=%s$" % (lexp[0] * lexp[1], decimaux(10 ** (lexp[0] * lexp[1]), 1))) elif j == 2: while abs(lexp[0] - lexp[1]) > 10: lexp = [randrange(-6, 6) for i in range(2)] exo.append("\\item $\\dfrac{10^{%s}}{10^{%s}}=\\dotfill$" % tuple(lexp)) cor.append("\\item $\\dfrac{10^{%s}}{10^{%s}}=" % tuple(lexp)) cor.append("10^{%s-%s}=" % (lexp[0], tex_coef(lexp[1], '', bpn=1))) cor.append("10^{%s}=%s$" % (lexp[0] - lexp[1], decimaux(10 ** (lexp[0] - lexp[1]), 1))) exo.append("\\end{enumerate}") exo.append("\\end{multicols}\n") cor.append("\\end{enumerate}") cor.append("\\end{multicols}\n") return (exo, cor, question)
def tex_equations(valeurs, variable, cor): # renvoie un tuple contenant les deux binomes egaux a 0 cor.append("\\begin{center}") cor.append("$\\begin{aligned}") cor.append("%s & =0 & & \\text{ou} & %s &= 0 \\\\" % (tex_binome(valeurs[0], variable), tex_binome(valeurs[1], variable))) eq = equations1(valeurs) if not isinstance(eq, tuple): cor.append("\\text{Aucune } & \\text{solution} & & \\text{ou} & \\text{Aucune } & \\text{solution} \\\\") cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u"L'équation a \\fbox{aucune solution.}") elif not isinstance(eq[0], tuple): cor.append("\\text{Aucune } & \\text{solution} & & \\text{ou} & %s & = %s \\\\" %(tex_coef(eq[1][0], variable), eq[1][1])) if eq[1][0] != 1: cor.append("\\text{Aucune } & \\text{solution} & & \\text{ou} & x & = %s \\\\" %tex_frac(equations2(eq)[1])) cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u'La solution est $\\boxed{%s}$' % tex_frac(equations3(eq)[1])) elif not isinstance(eq[1], tuple): cor.append(" %s & = %s & & \\text{ou} & \\text{Aucune } & \\text{solution} \\\\" %(tex_coef(eq[0][0], variable), eq[0][1])) if eq[0][0] != 1: cor.append(" x & = %s & & \\text{ou} & \\text{Aucune } & \\text{solution} \\\\" %tex_frac(equations2(eq)[0])) cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u'La solution est $\\boxed{%s}$' % tex_frac(equations3(eq)[0])) else: cor.append("%s & = %s & & \\text{ou} & %s & = %s \\\\" %(tex_coef(eq[0][0], variable), eq[0][1], tex_coef(eq[1][0], variable), eq[1][1])) if eq[0][0] != 1 or eq[1][0] != 1: cor.append("x & = %s & & \\text{ou} & x & = %s \\\\" %(tex_frac(equations2(eq)[0]), tex_frac(equations2(eq)[1]))) cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u'Les solutions sont $\\boxed{%s\\,\\text{ et }\\,%s}$' % (tex_frac(equations3(eq)[0]), tex_frac(equations3(eq)[1])))
def tex_valeurx2(a, nb): if nb == (0, 1): return '' else: if a[0][1] == a[1][1] == 1: return tex_coef(a[0][0] + a[1][0] + a[2][0], '') else: c = den_com0(a[0], a[1]) texte = '' if a[0][0] != 0: texte = tex_coef(1, tex_frac((a[0][0] * c[0], a[0][1] * c[0]))) if a[1][0] != 0: texte = texte + tex_coef(1, tex_frac((a[1][0] * c[1], a[1][1] * c[1])), bplus=texte) if a[2][0] != 0: texte = texte + tex_coef(1, tex_frac(((a[2][0] * a[0][1]) * c[0], a[0][1] * c[0])), bplus=texte) return texte
def CalculDistributivite(parametre): question = u"Calculer astucieusement :" exo = [] cor = [] valeur = valeurs_calcul_distr(parametre[0], parametre[1]) exo.append("$$ A = %s \\times %s $$" % (tex_coef(valeur[0][0]+valeur[0][1], ''), tex_coef(valeur[1][0]+valeur[1][1], '', 0, 1))) cor.append("\\begin{center}") cor.append("$\\begin{aligned}") cor.append("A & = %s \\times %s \\\\" % (tex_coef(valeur[0][0]+valeur[0][1], ''), tex_coef(valeur[1][0]+valeur[1][1], '', 0, 1))) if abs(valeur[0][0])+ abs(valeur[1][0]): cor.append("A & = %s \\\\" %tex_dev0(valeur, '')) cor.append("A & = %s \\\\" %tex_dev1(valeur, '')) cor.append("A & = %s \\\\" %tex_trinome(dev(valeur), '')) cor.append("A & = \\boxed{%s} \\\\" %(dev(valeur)[0]+dev(valeur)[1]+dev(valeur)[2])) cor.append("\\end{aligned}$") cor.append("\\end{center}") return (exo, cor, question)
def tex_exercice(nombre_min, nombre_max, operation, style): question = "Calculer :" exo = [] cor = [] if operation == 0: (a, b) = plus(nombre_min, nombre_max) choix_trou(a, tex_coef(b, '', bpn=1), a + b, '+', exo, cor, style) if operation == 1: (a, b) = moins(nombre_min, nombre_max) choix_trou(a, tex_coef(b, '', bpn=1), a - b, '-', exo, cor, style) if operation == 2: (a, b) = plus(nombre_min, nombre_max) choix_trou(a, tex_coef(b, '', bpn=1), a * b, '\\times', exo, cor, style) if operation == 3: (a, b) = div(nombre_min, nombre_max) choix_trou(a, tex_coef(b, '', bpn=1), a // b, '\\div', exo, cor, style) return (exo, cor, question)
def solveur(enonce,equation,inconnue,corrige=False): enonce.append("\\begin{center}") enonce.append("$\\begin{aligned}") enonce.append("%s & = %s \\\\" %(tex_binome(equation[:2],inconnue),tex_binome(equation[2:],inconnue))) if corrige: if equation[1]!=0: enonce.append("%s & = %s \\red %s \\\\" %(tex_coef(equation[0],inconnue),tex_binome([equation[2],equation[3]],inconnue),tex_coef(-equation[1],0,1))) if equation[2]!=0 and equation[0]!=1: enonce.append("%s & = %s \\\\" %(tex_coef(equation[0],inconnue),tex_binome([equation[2],equation[3]-equation[1]],inconnue))) if equation[2]!=0: enonce.append("%s \\red %s \\black & = %s \\\\" %(tex_coef(equation[0],inconnue),tex_coef(-equation[2],inconnue,1),tex_coef(equation[3]-equation[1],0))) enonce.append("%s & = %s \\\\" %(tex_coef(equation[0]-equation[2],inconnue),tex_coef(equation[3]-equation[1],0))) if (equation[0]-equation[2])!=1: enonce.append("%s & = %s \\div \\red %s \\\\" %(inconnue,tex_coef(equation[3]-equation[1],0),tex_coef(equation[0]-equation[2],0,0,1))) if float(equation[3]-equation[1])/(equation[0]-equation[2]) != (equation[3]-equation[1])/(equation[0]-equation[2]): enonce.append("%s & \\approx \\boxed{%s} \\\\" %(inconnue,round(float(equation[3]-equation[1])/(equation[0]-equation[2]),2))) else: enonce.append("%s & = \\boxed{%s} \\\\" %(inconnue,(equation[3]-equation[1])/(equation[0]-equation[2]))) enonce.append("\\end{aligned}$") enonce.append("\\end{center}")
def tex_valeurx1(a, nb): if nb == (0, 1): return tex_coef(a[2], '') elif nb[1] == 1: return tex_coef(a[0] * nb[0] ** 2, '') + tex_coef(a[1] * nb[0], '', bplus=a[0]) + tex_coef(a[2], '', bplus=a[0] or a[1]) else: texte = '' if a[0] != 0: a0 = ((a[0], 1), (nb[0] ** 2, nb[1] ** 2)) if isinstance(decomp_prod(a0[0], a0[1])[2], tuple): texte = tex_coef(1, tex_decomp_prod(decomp_prod(a0[0], a0[1]))) else: texte = tex_coef(1, tex_frac(produit(a0[0], a0[1]))) if a[1] != 0: a1 = ((a[1], 1), (nb[0], nb[1])) if isinstance(decomp_prod(a1[0], a1[1])[2], tuple): texte = texte + tex_coef(1, tex_decomp_prod(decomp_prod(a1[0], a1[1])), bplus=a[0]) else: texte = texte + tex_coef(1, tex_frac(produit(a1[0], a1[1])), bplus=a[0]) texte = texte + tex_coef(a[2], '', bplus=1) return texte
def tex_valeurx0(a, nb): if nb == (0, 1): return '%s%s%s' % (tex_coef(a[0], '%s^2' % tex_frac(nb)), tex_coef(a[1], '%s' % tex_frac(nb),bplus=a[0]), tex_coef(a[2], '', bplus=a[0] or a[1])) else: return '%s%s%s' % (tex_coef(a[0], '\\left(%s\\right)^2' % tex_frac(nb)), tex_coef(a[1], '\\left(%s\\right)' % tex_frac(nb), bplus=a[0]), tex_coef(a[2], '', bplus=a[0] or a[1]))