コード例 #1
0
def tex_somme(exo, cor,nbre_min, nbre_max, nbre_decimal_1, nbre_decimal_2):
    (ligne1, ligne2) = ([''], ['+'])
    (nba, nbb, deca, decb, lavtvirg, laprvirg) = valeurs(nbre_min, nbre_max, nbre_decimal_1, nbre_decimal_2)
    total = nba + nbb
    dectotal = [str(total)[i] for i in range(len(str(total)))]
    if dectotal.count('.'):
        postotal = dectotal.index('.')
    else:
        postotal = len(dectotal)
    if postotal <= lavtvirg:
        ligne3 = ['']
    else:
        ligne3 = []
    ligne1 = lignes(ligne1, deca, lavtvirg, laprvirg)
    ligne2 = lignes(ligne2, decb, lavtvirg, laprvirg)
    ligne3 = lignes(ligne3, dectotal, lavtvirg, laprvirg)
    ligne0 = retenues_somme(ligne1, ligne2)
    if ligne0[0] == '1':
        ligne0[0] = '\\tiny 1'
    exo.append('$$ %s + %s = \\ldots $$' % (Affichage.decimaux(nba), Affichage.decimaux(nbb)))
    cor.append('\\begin{center}')
    cor.append('\\begin{footnotesize}')
    cor.append('\\begin{tabular}[t]{*{%s}{c}}' % (lavtvirg + laprvirg + 1))
    cor.append('%s \\\\' % ' & \\tiny '.join(ligne0))
    cor.append('%s \\\\' % ' & '.join(ligne1))
    cor.append('%s \\\\\n\\hline' % ' & '.join(ligne2))
    cor.append('%s \\\\' % ' & '.join(ligne3))
    cor.append('\\end{tabular}\\par')
    cor.append('\\end{footnotesize}')
    cor.append('\\end{center}')
    formule = '%s+%s = %s' % (Affichage.decimaux(nba, 1), Affichage.decimaux(nbb, 1), Affichage.decimaux(nba + nbb, 1))
    cor.append((u'\\[ \\boxed{%s} \\] ').expandtabs(2 * 3) % (formule))
コード例 #2
0
def classer(exo, cor):
    lnb = choix_nombres()
    random.shuffle(lnb)
    if random.randrange(2):
        ordre = "croissant"
    else:
        ordre = u"décroissant"
    exo.append("\\item Classer les nombres suivants dans l'ordre %s.\\par    " %
             ordre)
    cor.append("\\item Classer les nombres suivants dans l'ordre %s.\\par    " %
             ordre)
    str=""
    for i in range(len(lnb)):
        if i:
            str += " \\kern1cm ; \\kern1cm "
        str += Affichage.decimaux(lnb[i], 0)
    exo.append(str)
    cor.append(str + "\\par")
    lnb.sort()
    if ordre == "croissant":
        ordre = "\\textless"
    else:
        ordre = "\\textgreater"
        lnb.reverse()
    str=""
    for i in range(len(lnb)):
        if i:
            str +=" \\kern1cm %s \\kern1cm " % ordre
        str += Affichage.decimaux(lnb[i], 0)
    cor.append(str)
コード例 #3
0
def tex_conversion(exo, cor, exposant, u):
    """Écrit une question sur les conversions d'unités d'aires ou de volume
    et le corrigé au format LaTeX
    @param exo: fichier exercices
    @param cor: fichier corrige
    exposant = 2 ou 3 pour les aires ou les volumes
    """

    a = random.randint(101,999)
    p = random.randint(-2,-1)
    while True:
        (div0,div1)=(random.randrange(6),random.randrange(7),)
        #Pas de mm³ par ce que ça sort du tableau
        if (div0-div1) in [-2,-1,1,2]:
            #pas trop loin car ça fait de très longs nombres
            break
    nb0 = a * 10 ** p
    nb1 = nb0 * 10 ** ( exposant * ( div1- div0))

    exo.append("\\item $\\unit[%s]{%s}=\\unit[\\dotfill]{%s}$"%
            (Affichage.decimaux(nb0), u[div0], u[div1]))
    cor.append("\\item $\\unit[%s]{%s}=\\unit[%s]{%s}$\\vspace{1ex}\\par" %
            (Affichage.decimaux(nb0), u[div0],
                Affichage.decimaux(nb1), u[div1]))

    return tex_tableau_conversion(div0, div1, nb0, u, exposant)
コード例 #4
0
def EcritEnLettre(exo, cor):
    lnb = nombreATrouver()
    for i in range(8):
        exo.append("\\item " + Affichage.decimaux(lnb[i], 0) +
                 " : \\dotfill")
        cor.append("\\item " + Affichage.decimaux(lnb[i], 0) +
                " : ")
        cor.append(EcritNombreDecimal(lnb[i]) + '')
コード例 #5
0
def exo_conversion_longueur(parametre):
    """
    Écrit l'exercice sur les conversions d'unités et le corrigé au format
    LaTeX
    @param exo: fichier exercices
    @param cor: fichier corrige
    """
    question = ""
    exo = ['Effectuer les conversions suivantes :',
            '\\begin{multicols}{3}\\noindent', '\\begin{enumerate}']
    cor = [ #paramétrage des flèches, ce paramétrage est limité à l'exercice
            # et ne modifie pas le paramétrage PSTricks du document car sa portée est limité par le groupe ouvert par "{"
           "{",
            PSSET_FLECHE,
           'Effectuer les conversions suivantes :',
            '\\begin{multicols}{2}\\noindent', '\\begin{enumerate}']

    #Construit les 6 questions de l'exercice
    for i in range(6):
        (a, p, unit, div0, div1) = valeurs_units()
        if unit:
            u = tuple([units[unit] for i in range(7)])
        else:
            u = tuple([units[unit] for i in range(6)])
        nb0 = Affichage.decimaux(a * 10 ** p, 0)
        nb1 = Affichage.decimaux(a * 10 ** ((p + div1) - div0),
                0)
        exo.append("\\item %s~%s%s=\dotfill~%s%s" % (nb0, division[div0],
                 units[unit], division[div1], units[unit]))
        cor.append("\\item %s~%s%s=%s~%s%s\\par" % (nb0, division[div0],
                 units[unit], nb1, division[div1], units[unit]))
        nblist = [nb0[i] for i in range(len(nb0))]
        if nblist.count(','):
            chf_unite = nblist.index(',') - 1
            nblist.pop(chf_unite + 1)
        else:
            chf_unite = len(nblist) - 1

        tex_tableau(cor, div0, div1, u, nblist, chf_unite)

        cor.append("\\end{tabular}")
        cor.append("\\ncline{->}{virg0}{virg1}")

    exo.append('\\end{enumerate}')
    exo.append('\\end{multicols}')
    cor.append('\\end{enumerate}')
    cor.append('\\end{multicols}')
    #ferme le groupe limitant la portée de PSSET_FLECHE
    cor.append('}')
    return (exo, cor, question)
コード例 #6
0
def tex_place_virgule(exo, cor):
    """
    Écrit un exercices demandant de placer une virgule dans un nombre.
    @param exo: fichier exerices
    @param cor:fichier corrigé
    """

    valeurs_index = [0, 1, 2, 3, 4, 5, 6]
    nb = valeurs_decimaux()
    exo.append(u"Placer une virgule (en ajoutant éventuellement des zéros) dans\
            le nombre %s de telle sorte que :" % nb)
    exo.append('\\begin{enumerate}')
    cor.append(u"Placer une virgule (en ajoutant éventuellement des zéros) dans\
            le nombre %s de telle sorte que :" % nb)
    cor.append('\\begin{enumerate}')
    for i in range(6):
        dec = [str(nb)[i] for i in range(len(str(nb)))]
        index_dec = random.randrange(6)
        index_valeurs = valeurs_index.pop(random.randrange(len(valeurs_index)))
        exo.append(u"\\item le chiffre %s soit le chiffre des %s : " \
                 % (dec[index_dec], valeurs[index_valeurs]))
        cor.append(u"\\item le chiffre %s soit le chiffre des %s : " \
                 % (dec[index_dec], valeurs[index_valeurs]))
        resultat = ecrit_nombre_decimal(dec, (index_dec + 4) -
                index_valeurs)
        exo.append('\\dotfill')
        cor.append(Affichage.decimaux(resultat, 0) + '')
    exo.append('\\end{enumerate}')
    cor.append('\\end{enumerate}')
コード例 #7
0
def triangle_base(dim, n_fig):
    """Dessine en psTricks un triangle avec une base horizontale ou verticale
    dans une boite de dimensions dim et numérote la figure avec n_fig"""
    sommets = [(0, 0), (dim[0], 0), dim, (0, dim[1])]
    s0 = random.randrange(4)
    s1 = (s0+1)%4
    x0, x1 = sommets[(s0+2)%4][0], sommets[(s0+3)%4][0]
    y0, y1 = sommets[(s0+2)%4][1], sommets[(s0+3)%4][1]
    if x0>x1: x0, x1 = x1, x0
    if y0>y1: y0, y1 = y1, y0
    if x0 != x1: x0 = random.randrange(x0+1, x1)
    if y0 != y1: y0 = random.randrange(y0+1, y1)
    s2 = (x0, y0)
    s0, s1 = sommets[s0], sommets[s1]
    f = "\\pspolygon[fillstyle=hlines]%s%s%s\n" % (s0, s1,
            s2)
    f += "\\rput(%.2f,%.2f)" % isobarycentre(s0, s1, s2)
    f += "{\\psframebox[linecolor=white, fillcolor=white, fillstyle=solid]{figure %s}} " %  n_fig
    fc = "\\psframe[linestyle=dashed]%s%s\n" % (s0, s2)
    fc += "\\psframe[linestyle=dashed]%s%s\n" % (s2, s1)
    fc += f
    s = "Aire de la figure %s : " % n_fig
    s += u"c'est la moitié de l'aire du rectangle en pointillés.\\par\n"
    s += u"$(%s) \\div 2= %s$~unités d'aire" %(aire_rectangle(dim)[0],
            Affichage.decimaux(aire_rectangle(dim)[1]/2., 1))
    return f, fc, s
コード例 #8
0
def tex_difference(exo, cor):
    (ligne1, ligne2) = ([''], ['-'])
    (nba, nbb, deca, decb, lavtvirg, laprvirg) = valeurs()
    if nba < nbb:
        (nba, nbb, deca, decb) = (nbb, nba, decb, deca)
    total = nba - nbb
    dectotal = [str(total)[i] for i in range(len(str(total)))]
    if dectotal.index('.') <= lavtvirg:
        ligne3 = ['']
    else:
        ligne3 = []
    ligne1 = lignes(ligne1, deca, lavtvirg, laprvirg)
    ligne2 = lignes(ligne2, decb, lavtvirg, laprvirg)
    ligne3 = lignes(ligne3, dectotal, lavtvirg, laprvirg)
    (ligne1, ligne2) = retenues_diff(ligne1, ligne2)
    exo.append(u"\\item La différence des termes %s et %s.\\par" %
             (Affichage.decimaux(nba), Affichage.decimaux(nbb)))
    cor.append(u"\\item La différence des termes %s et %s.\\par" %
             (Affichage.decimaux(nba), Affichage.decimaux(nbb)))
    cor.append('\\begin{tabular}[t]{*{%s}{c}}' % (lavtvirg +
             laprvirg + 1))
    cor.append('%s \\\\' % ' & '.join(ligne1))
    cor.append('%s \\\\\n\\hline' % ' & '.join(ligne2))
    cor.append('%s \\\\' % ' & '.join(ligne3))
    cor.append('\\end{tabular}\\par')
    formule = '%s-%s = %s' % (Affichage.decimaux(nba, 1),
                     Affichage.decimaux(nbb, 1), Affichage.decimaux(nba -
                     nbb, 1))
    cor.append((u'\\[ \\boxed{%s} \\] ').expandtabs(2 * 3) % (formule))
コード例 #9
0
def tex_somme(exo, cor):
    (ligne1, ligne2) = ([''], ['+'])
    (nba, nbb, deca, decb, lavtvirg, laprvirg) = valeurs()
    total = nba + nbb
    dectotal = [str(total)[i] for i in range(len(str(total)))]
    if dectotal.index('.') <= lavtvirg:
        ligne3 = ['']
    else:
        ligne3 = []
    ligne1 = lignes(ligne1, deca, lavtvirg, laprvirg)
    ligne2 = lignes(ligne2, decb, lavtvirg, laprvirg)
    ligne3 = lignes(ligne3, dectotal, lavtvirg, laprvirg)
    ligne0 = retenues_somme(ligne1, ligne2)
    if ligne0[0] == '1':
        ligne0[0] = '\\tiny 1'
    exo.append('\\item La somme des termes %s et %s.\\par' % (Affichage.decimaux(nba),
             Affichage.decimaux(nbb)))
    cor.append('\\item La somme des termes %s et %s.\\par' % (Affichage.decimaux(nba),
             Affichage.decimaux(nbb)))
    cor.append('\\begin{tabular}[t]{*{%s}{c}}' % (lavtvirg +
             laprvirg + 1))
    cor.append('%s \\\\' % ' & \\tiny '.join(ligne0))
    cor.append('%s \\\\' % ' & '.join(ligne1))
    cor.append('%s \\\\\n\\hline' % ' & '.join(ligne2))
    cor.append('%s \\\\' % ' & '.join(ligne3))
    cor.append('\\end{tabular}\\par')
    formule = '%s+%s = %s' % (Affichage.decimaux(nba, 1),
                     Affichage.decimaux(nbb, 1), Affichage.decimaux(nba +
                     nbb, 1))
    cor.append((u'\\[ \\boxed{%s} \\] ').expandtabs(2 * 3) % (formule))
コード例 #10
0
def tex_decomposition(v, p):
    (exo, cor) = (["$$"], ["$$"])
    for i in range(3):
        if p[i] < 0:
            exo.append('%s\\times \\cfrac{1}{%s}' % (v[i], Affichage.decimaux(10 ** (-p[i]), 1)))
            cor.append('%s\\times \\cfrac{1}{%s}' % (v[i], Affichage.decimaux(10 ** (-p[i]), 1)))
        else:
            exo.append('%s\\times %s' % (v[i], Affichage.decimaux(10 ** p[i], 1)))
            cor.append('%s\\times %s' % (v[i], Affichage.decimaux(10 ** p[i], 1)))
        if i < 2:
            exo.append('+')
            cor.append('+')
        else:
            exo.append('=')
            cor.append('=')
    exo.append('\\ldots$$')
    cor.append('\\boxed{%s}$$' % Affichage.decimaux(v[0] * 10 ** p[0] + v[1] * 10 ** p[1] + v[2] * 10 ** p[2], 1))
    return " ".join(exo), " ".join(cor)
コード例 #11
0
def tex_produit(exo, cor):
    (nba, nbb, puisa, puisb) = valeurs_prod()
    deca = [','.join(str(nba * 10 ** puisa).rsplit('.'))[i] \
                    for i in range(len(str(nba * 10 ** puisa)))]
    decb = [','.join(str(nbb * 10 ** puisb).rsplit('.'))[i] \
                    for i in range(len(str(nbb * 10 ** puisb)))]

    (dec3, total) = pose_mult(nba, nbb)
    (dec3bis, total) = pose_mult(nbb, nba)
    total = ((nba * 10 ** puisa) * nbb) * 10 ** puisb
    dec4 = [str(total)[i] for i in range(len(str(total)))]
    if dec4.count('.'):
        i = dec4.index('.')
        if (len(dec4) - i) - 1 < -(puisa + puisb):
            for j in range(-(puisa + puisb) - len(dec4) + i + 1):
                dec4.append('0')  #ajoute les 0 inutiles au produit
        dec4.pop(i)  # supprime le point décimal
        dec4[i - 1] = '%s\\Huge ,' % dec4[i - 1]  # et ajoute une Huge virgule au chiffre des unités
    lg = max(len(dec4), max(len(deca), len(decb)))  # nombre de colonnes dans le tableau
    exo.append('\\item Le produit des facteurs %s et %s.\\par' % (Affichage.decimaux(nba *
             10 ** puisa), Affichage.decimaux(nbb * 10 ** puisb)))
    cor.append('\\item Le produit des facteurs %s et %s.\\par' % (Affichage.decimaux(nba *
             10 ** puisa), Affichage.decimaux(nbb * 10 ** puisb)))
    cor.append('\\begin{enumerate}')
    cor.append(u'\\item Première méthode :\\par')
    cor.append('\\begin{tabular}[t]{*{%s}{c}}' % lg)
    cor.append('%s \\\\' % ' & '.join(ligneprod([], deca,lg)))
    cor.append('%s \\\\\n\\hline' % ' & '.join(ligneprod(['$\\times$'], decb, lg)))
    for i in range(len(dec3)):
        dec = [str(dec3[i])[j] for j in range(len(str(dec3[i])))]
        cor.append('%s \\\\' % ' & '.join(ligneprod([], dec, lg)))
    cor.append('\\hline \\\\')
    cor.append('%s \\\\' % ' & '.join(ligneprod([], dec4, lg)))
    cor.append('\\end{tabular}')
    cor.append(u'\\item Seconde méthode :\\par')
    cor.append('\\begin{tabular}[t]{*{%s}{c}}' % len(dec4))
    cor.append('%s \\\\' % ' & '.join(ligneprod([], decb, lg)))
    cor.append('%s \\\\\n\\hline' % ' & '.join(ligneprod(['$\\times$'], deca, lg)))
    for i in range(len(dec3bis)):
        dec = [str(dec3bis[i])[j] for j in range(len(str(dec3bis[i])))]
        cor.append('%s \\\\' % ' & '.join(ligneprod([], dec, lg)))
    cor.append('\\hline \\\\')
    cor.append('%s \\\\' % ' & '.join(ligneprod([], dec4, lg)))
    cor.append('\\end{tabular}')
    cor.append('\\end{enumerate}')

    #outils.Arithmetique.ecrit_tex(f1, '%s\\times%s = %s' % (Affichage.decimaux(nba *
                     #10 ** puisa, 1), Affichage.decimaux(nbb * 10 **
                     #puisb, 1), Affichage.decimaux((nba * nbb) * 10 ** (puisa +
                     #puisb), 1)), cadre=1, thenocalcul='', tabs=3)

    #### Remplacement de la fonction Arithmetique.ecrit_tex :

    formule = '%s\\times%s = %s' % (Affichage.decimaux(nba *
                     10 ** puisa, 1), Affichage.decimaux(nbb * 10 **
                     puisb, 1), Affichage.decimaux((nba * nbb) * 10 ** (puisa +
                     puisb), 1))
    cor.append((u'\\[ \\boxed{%s} \\] ').expandtabs(2 * 3) % (formule))
コード例 #12
0
def EcritEnLettreDecimal(parametre):
    question = u"Écrire en lettres :"
    exo = []
    cor = []
    lnb = nombreATrouver(parametre[0], parametre[1], 1)
    exo.append("\\begin{center}")
    cor.append("\\begin{center}")
    exo.append(Affichage.decimaux(lnb, 0))
    cor.append(EcritNombreDecimal(lnb))
    exo.append("\\end{center}")
    cor.append("\\end{center}")
    return (exo, cor, question)
コード例 #13
0
def tex_produit(exo, cor, nbre_min, nbre_max, nbre_decimal_1, nbre_decimal_2):
    (nba, nbb, puisa, puisb) = valeurs_prod(nbre_min, nbre_max, nbre_decimal_1, nbre_decimal_2)
    deca = [str(nba * 10 ** puisa)[i] for i in range(len(str(nba * 10 ** puisa)))]
    decb = [str(nbb * 10 ** puisb)[i] for i in range(len(str(nbb * 10 ** puisb)))]
    if deca.count('.'):
        i = deca.index('.')
        deca.pop(i)
        deca[i - 1] = '%s ,' % deca[i - 1]
    if decb.count('.'):
        i = decb.index('.')
        decb.pop(i)
        decb[i - 1] = '%s ,' % decb[i - 1] 
    (dec3, total) = pose_mult(nba, nbb)
    total = ((nba * 10 ** puisa) * nbb) * 10 ** puisb
    dec4 = [str(total)[i] for i in range(len(str(total)))]
    if dec4.count('.'):
        i = dec4.index('.')
        if (len(dec4) - i) - 1 < -(puisa + puisb):
            for j in range(-(puisa + puisb) - len(dec4) + i + 1):
                dec4.append('0')  #ajoute les 0 inutiles au produit
        dec4.pop(i)  # supprime le point décimal
        dec4[i - 1] = '%s ,' % dec4[i - 1]  # et ajoute une virgule au chiffre des unités
    lg = max(len(dec4), len(deca), len(decb)+1)  # nombre de colonnes dans le tableau
    exo.append('$$ %s \\times %s = \\ldots $$' % (Affichage.decimaux(nba *10 ** puisa), Affichage.decimaux(nbb * 10 ** puisb)))
    cor.append('\\begin{center}')
    cor.append('\\begin{tabular}[t]{*{%s}{c}}' % lg)
    cor.append('%s \\\\' % ' & '.join(ligneprod([], deca,lg)))
    cor.append('%s \\\\\n\\hline' % ' & '.join(ligneprod(['$\\times$'], decb, lg)))

    if len(dec3) > 1:
        for i in range(len(dec3)):
            dec = [str(dec3[i])[j] for j in range(len(str(dec3[i])))]
            cor.append('%s \\\\' % ' & '.join(ligneprod([], dec, lg)))
        cor.append('\\hline')

    cor.append('%s \\\\' % ' & '.join(ligneprod([], dec4, lg)))
    cor.append('\\end{tabular}')
    cor.append('\\end{center}')
    formule = '%s\\times%s = %s' % (Affichage.decimaux(nba *10 ** puisa, 1), Affichage.decimaux(nbb * 10 **puisb, 1), Affichage.decimaux((nba * nbb) * 10 ** (puisa + puisb), 1))
    cor.append((u'\\[ \\boxed{%s} \\] ').expandtabs(2 * 3) % (formule))
コード例 #14
0
def tex_exercice(exo,cor,exposant):
    # variable
    a = random.randint(101,999)
    p = random.randint(-2,-1)
    while True:
        (div0,div1)=(random.randrange(6),random.randrange(7))
        #Pas de mm³ par ce que ça sort du tableau
        if (div0-div1) in [-2,-1,1,2]:
            #pas trop loin car ça fait de très longs nombres
            break
    nb0 = a * 10 ** p
    nb1 = nb0 * 10 ** ( exposant * ( div1- div0))
    # unité
    str_exposant=(u"^%s"%(exposant))*(exposant > 1) #ajoute le ² ou ³ si nécessaire
    unite = tuple([division[i]+"m%s"%str_exposant for i in range(7)])
    ligne_enonce = [("" + "& "*(7*exposant-1))]
    ligne_corrige = tex_ligne_corrige(div0, div1, nb0, exposant) + ["\\ncline{->}{virg0}{virg1} \\\\"]
    #construction
    exo.append("$$\\unit[%s]{%s}=\\unit[\\ldots]{%s}$$"%(Affichage.decimaux(nb0), unite[div0], unite[div1]))
    cor.append("$$\\unit[%s]{%s}=\\unit[\\boxed{%s}]{%s}$$" % (Affichage.decimaux(nb0), unite[div0], Affichage.decimaux(nb1), unite[div1]))
    tex_tableau_conversion(exo, ligne_enonce, exposant, unite)
    tex_tableau_conversion(cor, ligne_corrige, exposant, unite)
コード例 #15
0
def ClasserNombres(parametre):
    # Choix de l'ordre
    if random.randrange(2):
        ordre = "croissant"
    else:
        ordre = u"décroissant"
    # Entête
    question = "Classer dans l'ordre %s :" % ordre
    exo = []
    cor = []
    exo.append("\\begin{center}")
    cor.append("\\begin{center}")
    lnb = choix_nombres()
    random.shuffle(lnb)
    str=""
    for i in range(len(lnb)):
        if i:
            str += " || "
        str += Affichage.decimaux(lnb[i], 0)
    exo.append(str)

    lnb.sort()
    if ordre == "croissant" or ordre == "\\textless":
        ordre = "\\textless"
    else:
        ordre = "\\textgreater"
        lnb.reverse()
    str=""
    for i in range(len(lnb)):
        if i:
            str +=" %s " % ordre
        str += Affichage.decimaux(lnb[i], 0)

    cor.append(str)
    exo.append("\\end{center}")
    cor.append("\\end{center}")
    return (exo, cor, question)
コード例 #16
0
def choix_trou_frac(exo, cor, n1, p1):
    i = random.randrange(3)
    p2 = random.randrange(2)  #sert à compliquer un peu l'exercice
    if i > 1:
        exo.append('$$\\cfrac{%s}{%s}=\\ldots$$' % (Affichage.decimaux(n1 * 10 ** p2), Affichage.decimaux(10 ** (p1 + p2))))
        cor.append('$$\\cfrac{%s}{%s}=\\boxed{%s}$$' % (Affichage.decimaux(n1 * 10 ** p2), Affichage.decimaux(10 ** (p1 + p2)), Affichage.decimaux(n1 * 10 ** (-p1), 1)))
    elif i > 0:
        exo.append('$$\\cfrac{%s}{\ldots}=%s$$' % (Affichage.decimaux(n1 * 10 ** p2), Affichage.decimaux(n1 * 10 ** (-p1), 1)))
        cor.append('$$\\cfrac{%s}{\\boxed{%s}}=%s$$' % (Affichage.decimaux(n1 * 10 ** p2), Affichage.decimaux(10 ** (p1 + p2)), Affichage.decimaux(n1 * 10 ** (-p1), 1)))
    else:
        exo.append('$$\\cfrac{\ldots}{%s}=%s$$' % (Affichage.decimaux(10 ** (p1 + p2)), Affichage.decimaux(n1 * 10 ** (-p1), 1)))
        cor.append('$$\\cfrac{\\boxed{%s}}{%s}=%s$$' % (Affichage.decimaux(n1 * 10 ** p2), Affichage.decimaux(10 ** (p1 + p2)), Affichage.decimaux(n1 * 10 ** (-p1), 1)))
コード例 #17
0
def triangle_rectangle(dim, n_fig):
    """Dessine en psTricks un triangle rectangle dans une boite de dimensions
    dim et numérote la figure avec n_fig"""
    sommets = [(0, 0), (dim[0], 0), dim, (0, dim[1])]
    s0 = random.randrange(4)
    s1, s2 = (s0+1)%4, (s0+2)%4
    s0, s1, s2 = sommets[s0], sommets[s1], sommets[s2]
    f = "\\pspolygon[fillstyle=hlines]%s%s%s\n" % (s0, s1,
            s2)
    f += "\\rput(%.2f,%.2f)" % isobarycentre(s0, s1, s2)
    f += "{\\psframebox[linecolor=white, fillcolor=white, fillstyle=solid]{figure %s}} " %  n_fig
    fc = "\\psframe[linestyle=dashed]%s%s\n" % (s0, s2)
    fc += f
    s = "Aire de la figure %s : " % n_fig
    s += u"c'est la moitié de l'aire du rectangle en pointillés.\\par\n"
    s += u"$(%s) \\div 2= %s$~unités d'aire" %(aire_rectangle(dim)[0],
            Affichage.decimaux(aire_rectangle(dim)[1]/2., 1))
    return f, fc, s
コード例 #18
0
def PlaceVirgule(parametre):
    # Parametres
    while True:
        (nombre, longueur_nombre, nombre_list) = valeurs_decimaux()
        index_chiffre = random.randrange(longueur_nombre)
        index_rang = random.randrange(parametre[0]+8, parametre[1]+8)
        decallage = index_chiffre+index_rang-7
        if longueur_nombre - decallage != 0:
            break
    # initialisa
    question = u"Modifie %s pour que:" % nombre
    exo = []
    cor = []
    exo.append("\\begin{center}")
    exo.append(u"%s soit le chiffre des %s" % (nombre_list[index_chiffre], rang[index_rang]))
    exo.append("\\end{center}")
    cor.append(u"\\textbf{%s est le chiffre des %s de :}" % (nombre_list[index_chiffre], rang[index_rang]))
    resultat = ecrit_nombre_decimal(nombre_list, decallage)
    cor.append("$$%s$$" %Affichage.decimaux(resultat, 0))
    return (exo, cor, question)
コード例 #19
0
def triangle_qcq(dim, n_fig):
    """Dessine en psTricks un triangle quelconque dans une boite de dimensions
    dim et numérote la figure avec n_fig"""
    sommets = [(0, 0), (dim[0], 0), dim, (0, dim[1])]
    s0 = random.randrange(4)
    angle0, angle1, angle2 = sommets[(s0+1)%4], sommets[(s0+2)%4], sommets[(s0+3)%4]
    x0, x1 = sommets[(s0+1)%4][0], sommets[(s0+2)%4][0]
    y0, y1 = sommets[(s0+1)%4][1], sommets[(s0+2)%4][1]
    if x0>x1: x0, x1 = x1, x0
    if y0>y1: y0, y1 = y1, y0
    if x0 != x1: x0 = random.randrange(x0+1, x1)
    if y0 != y1: y0 = random.randrange(y0+1, y1)
    s1 = (x0, y0)
    x0, x1 = sommets[(s0+2)%4][0], sommets[(s0+3)%4][0]
    y0, y1 = sommets[(s0+2)%4][1], sommets[(s0+3)%4][1]
    if x0>x1: x0, x1 = x1, x0
    if y0>y1: y0, y1 = y1, y0
    if x0 != x1: x0 = random.randrange(x0+1, x1)
    if y0 != y1: y0 = random.randrange(y0+1, y1)
    s2 = (x0, y0)
    s0 = sommets[s0]
    f = "\\pspolygon[fillstyle=hlines]%s%s%s\n" % (s0, s1,
            s2)
    f += "\\rput(%.2f,%.2f)" % isobarycentre(s0, s1, s2)
    f += "{\\psframebox[linecolor=white, fillcolor=white, fillstyle=solid]{figure %s}}" %  n_fig
    fc = "\\psframe[linestyle=dashed](0,0)(%s,%s) " % dim
    fc += "\\rput(%.2f,%.2f){\\pscirclebox{1}} " % isobarycentre(s0, s1, angle0)
    fc += "\\rput(%.2f,%.2f){\\pscirclebox{2}} " % isobarycentre(s1, s2, angle1)
    fc += "\\rput(%.2f,%.2f){\\pscirclebox{3}}\n" % isobarycentre(s2, s0, angle2)
    fc += f
    s = "Aire de la figure %s : " % n_fig
    s += u"on calcule l'aire du rectangle en pointillés et on soustrait "
    s += "les aires des triangles rectangles \\pscirclebox{1}, "
    s += "\\pscirclebox{2} et \\pscirclebox{3}.\\par\n"
    s += "$(%s) - (%s) \\div 2 - (%s) \\div 2 - (%s) \\div 2 " %\
            (aire_rectangle(dim)[0], aire_rectangle(s0, s1)[0],
                    aire_rectangle(s1, s2)[0], aire_rectangle(s2, s0)[0])
    s += u"= %s$~unités d'aire" % Affichage.decimaux(aire_rectangle(dim)[1] -
            aire_rectangle(s0, s1)[1]/2. - aire_rectangle(s0, s2)[1]/2. -
            aire_rectangle(s1, s2)[1]/2., 1)
    return f, fc, s
コード例 #20
0
def tex_formule_dix(l, exo, cor):
    if l[2] == '*':
        alea = random.randrange(0, 5)
        if alea > 1:
            exo.append('$$%s \\quad\\times\\quad %s \\quad = \\quad \\ldots$$' %(Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],1)))
            cor.append('$$%s \\times %s = \\boxed{%s}$$' %(Affichage.decimaux(l[0],1),Affichage.decimaux(l[1],1), Affichage.decimaux(l[0] * l[1], 1)))
        elif alea > 0:
            exo.append('$$%s \\quad\\times\\quad \\ldots \\quad = \\quad %s$$' %(Affichage.decimaux(l[0], 1), Affichage.decimaux(l[0] *l[1], 1)))
            cor.append('$$%s \\times \\boxed{%s} = %s$$' % (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],1), Affichage.decimaux(l[0] * l[1], 1)))
        else:
            exo.append('$$\\ldots \\quad\\times\\quad %s \\quad = \\quad %s$$' %(Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] *l[1], 1)))
            cor.append('$$\\boxed{%s} \\times %s = %s$$' %(Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],1), Affichage.decimaux(l[0] * l[1], 1)))
    else:
        alea = random.randrange(0, 5)
        if alea > 1:
            exo.append('$$%s \\quad\\div\\quad %s \\quad = \\quad \\ldots$$' % (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],1)))
            cor.append('$$%s \\div %s = \\boxed{%s}$$' % (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] / l[1], 1)))
        elif alea > 0:
            exo.append('$$%s \\quad\\div\\quad \\ldots \\quad = \\quad %s$$' % (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[0] / l[1], 1)))
            cor.append('$$%s \\div \\boxed{%s} = %s$$' % (Affichage.decimaux(l[0],1), Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] / l[1], 1)))
        else:
            exo.append('$$\\ldots \\quad\\div\\quad %s \\quad = \\quad %s$$' % (Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] / l[1], 1)))
            cor.append('$$\\boxed{%s} \\div %s = %s$$' % (Affichage.decimaux(l[0],1), Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] / l[1], 1)))
コード例 #21
0
def tex_formule_dix(l, exo, cor):
    if l[2] == '*':
        alea = random.randrange(0, 5)
        if alea > 1:
            exo.append('\\item $%s \\quad\\times\\quad %s \\quad = \\quad \\dotfill$' %
                     (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],
                     1)))
            cor.append('\\item $%s \\times %s = \\mathbf{%s}$' %
                     (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],
                     1), Affichage.decimaux(l[0] * l[1], 1)))
        elif alea > 0:
            exo.append('\\item $%s \\quad\\times\\quad \\dotfill \\quad = \\quad %s$' %
                     (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[0] *
                     l[1], 1)))
            cor.append('\\item $%s \\times \\mathbf{%s} = %s$' %
                     (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],
                     1), Affichage.decimaux(l[0] * l[1], 1)))
        else:
            exo.append('\\item $\\dotfill \\quad\\times\\quad %s \\quad = \\quad %s$' %
                     (Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] *
                     l[1], 1)))
            cor.append('\\item $\\mathbf{%s} \\times %s = %s$' %
                     (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],
                     1), Affichage.decimaux(l[0] * l[1], 1)))
    else:
        alea = random.randrange(0, 5)
        if alea > 1:
            exo.append('\\item $%s \\quad\\div\\quad %s \\quad = \\quad \\dotfill$' %
                     (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[1],
                     1)))
            cor.append('\\item $%s \\div %s = \\mathbf{%s}$' % (Affichage.decimaux(l[0],
                     1), Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] /
                     l[1], 1)))
        elif alea > 0:
            exo.append('\\item $%s \\quad\\div\\quad \\dotfill \\quad = \\quad %s$' %
                     (Affichage.decimaux(l[0], 1), Affichage.decimaux(l[0] /
                     l[1], 1)))
            cor.append('\\item $%s \\div \\mathbf{%s} = %s$' % (Affichage.decimaux(l[0],
                     1), Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] /
                     l[1], 1)))
        else:
            exo.append('\\item $\\dotfill \\quad\\div\\quad %s \\quad = \\quad %s$' %
                     (Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] /
                     l[1], 1)))
            cor.append('\\item $\\mathbf{%s} \\div %s = %s$' % (Affichage.decimaux(l[0],
                     1), Affichage.decimaux(l[1], 1), Affichage.decimaux(l[0] /
                     l[1], 1)))