import new way for rotating numbers and example

This commit is contained in:
Lafrite 2014-08-29 14:33:04 +02:00
parent 48b5713862
commit 94bf43f945
3 changed files with 82 additions and 113 deletions

View File

@ -1,70 +0,0 @@
\documentclass[a4paper,10pt]{/media/documents/Cours/Prof/Enseignements/tools/style/classDS}
\usepackage{/media/documents/Cours/Prof/Enseignements/2013_2014}
% Title Page
\titre{Calcul littéral et statistiques}
% \quatreC \quatreD \troisB \troisPro
\classe{\troisB}
\date{26 septemble 2013}
% DS DSCorr DM DMCorr Corr
\typedoc{DS}
\duree{1 heure}
\sujet{%{{infos.subj%}}}
\begin{document}
\maketitle
\Calc
Le barème est donné à titre indicatif, il pourra être modifié.
\begin{Exo}[4.5]
Développer et réduire les expressions suivantes:
\begin{equation*}
A = %{{random.randint(1,9) %}}x (-%{{random.randint(1,9) %}}x + %{{random.randint(1,9) %}} )\qquad
B = (%{{random.randint(1,9) %}}x + %{{random.randint(1,9) %}})(-%{{random.randint(1,9) %}}x + %{{random.randint(1,9) %}}) \qquad
C = %{{random.randint(1,9) %}}x (-x + 1) + (%{{random.randint(1,9) %}}x + %{{random.randint(1,9) %}})(x - 4)
\end{equation*}
\end{Exo}
\begin{Exo}[4]
On cherche à évaluer l'aire du rectangle suivant:
\begin{center}
%\includegraphics[scale=0.3]{fig/rectangle}
\end{center}
\begin{enumerate}[a.]
\item En fonction de $x$, déterminer la hauteur puis la largeur du rectangle.
\item Exprimer l'aire du rectangle en fonction de $x$.
\item Réduire l'expression de l'aire.
\item Évaluer l'aire du rectangle quand $x = %{{random.randint(1,9) %}}$.
\end{enumerate}
\end{Exo}
\begin{Exo}[6]
Factoriser, en soulignant le terme commun, les expressions suivantes:
\begin{equation*}
A = 6x + 12 \qquad B = 21x + 7 \qquad C = 10x^2 - 5x + 25 \qquad D = 16x^2 - 24x
\end{equation*}
\end{Exo}
\begin{Exo}[5.5]
Voici les performances en saut en hauteur d'une classe de troisième. Les hauteurs sont données en centimètres.
\begin{equation*}
%{{ "; \\quad ".join(random.gaussRandomlist_strInt(120, 20, 10)) %}}
\end{equation*}
\begin{enumerate}[a.]
\item Quel est l'effectif total de cette série?
\item Quelle est l'étendue de cette série?
\item Déterminer la performance moyenne (notée $M$) des élèves de cette classe (On arrondira le résultat à l'unité).
\item Déterminer une performance médiane (notée $Me$).
\end{enumerate}
\end{Exo}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "master"
%%% End:

38
example.tpl.tex Normal file
View File

@ -0,0 +1,38 @@
\documentclass[a4paper,10pt]{/media/documents/Cours/Prof/Enseignements/tools/style/classDS}
\usepackage{/media/documents/Cours/Prof/Enseignements/2013_2014}
% Title Page
\titre{Calcul littéral et statistiques}
% \quatreC \quatreD \troisB \troisPro
\classe{\troisB}
\date{26 septemble 2013}
% DS DSCorr DM DMCorr Corr
\typedoc{DS}
\duree{1 heure}
\sujet{\Var{infos.subj}}
\begin{document}
\maketitle
\Calc
Le barème est donné à titre indicatif, il pourra être modifié.
\begin{Exo}[4.5]
\Block{set A = RdExpression("{a} / 2 + 2")()}
\Block{set B = RdExpression("{a} / 2 + 4")()}
Développer et réduire les expressions suivantes:
\begin{equation*}
A = \Var{ A } \\
B = \Var{ B }
\end{equation*}
\end{Exo}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "master"
%%% End:

View File

@ -4,48 +4,48 @@
import jinja2, random, os
import sys
import optparse
from rd_frac import frac
from pythagore import pythagore_triplet
from pymath.random_expression import RdExpression
def randfloat(approx = 1, low = 0, up = 10):
""" return a random number between low and up with approx floating points """
ans = random.random()
ans = ans*(up - low) + low
ans = round(ans, approx)
return ans
random.randfloat = randfloat
def gaussRandomlist(mu = 0, sigma = 1, size = 10, manip = lambda x:x):
""" return a list of a gaussian sample """
ans = []
for i in range(size):
ans += [manip(random.gauss(mu,sigma))]
return ans
random.gaussRandomlist = gaussRandomlist
def gaussRandomlist_strInt(mu = 0, sigma = 1, size = 10):
return gaussRandomlist(mu, sigma, size, manip = lambda x: str(int(x)))
random.gaussRandomlist_strInt = gaussRandomlist_strInt
random.frac = frac
random.pythagore = pythagore_triplet
report_renderer = jinja2.Environment(
block_start_string = '%{',
block_end_string = '%}',
variable_start_string = '%{{',
variable_end_string = '%}}',
loader = jinja2.FileSystemLoader(os.path.abspath('.'))
#texenv = jinja2.Environment(
# block_start_string = '%{',
# block_end_string = '%}',
# variable_start_string = '%{{',
# variable_end_string = '%}}',
# loader = jinja2.FileSystemLoader(os.path.abspath('.'))
#)
texenv = jinja2.Environment(
block_start_string = '\Block{',
# Gros WTF!! Si on le met en maj ça ne marche pas alors que c'est en maj dans le template...
block_end_string = '}',
variable_start_string = '\Var{',
variable_end_string = '}',
loader = jinja2.FileSystemLoader(os.path.abspath('.'))
)
# The environment
#report_renderer = jinja2.Environment(
# block_start_string = '\BLOCK{',
# block_end_string = '}',
# variable_start_string = '\VAR{',
# variable_end_string = '}',
# comment_start_string = '\#{',
# comment_end_string = '}',
# line_statement_prefix = '%-',
# line_comment_prefix = '%#',
# trim_blocks = True,
# autoescape = False,
# loader = jinja2.FileSystemLoader(os.path.abspath('.'))
#)
#texenv = jinja2.Environment()
#texenv.block_start_string = '\BLOCK{'
#texenv.block_end_string = '}'
#texenv.loader = jinja2.FileSystemLoader('.')
def main(options):
template = report_renderer.get_template(options.template)
#template = report_renderer.get_template(options.template)
template = texenv.get_template(options.template)
cwd = os.getcwd()
@ -56,20 +56,21 @@ def main(options):
output_name = tpl_base + "_"
output_dir = os.path.dirname(output_name)
if output_dir != "":
os.chdir(output_dir)
output_basename = os.path.basename(output_name)
output_tplname = output_basename.split("/")[-1]
os.chdir(output_dir)
for subj in range(options.num_subj):
subj = subj+1
dest = output_tplname + str(subj) + '.tex'
with open( dest, 'w') as f:
f.write(template.render(random = random, infos = {"subj" : subj}))
os.system("pdflatex " + dest)
f.write(template.render(plop = str(1), RdExpression = RdExpression , infos = {"subj" : subj}))
#os.system("pdflatex " + dest)
if not options.dirty:
os.system("rm *.aux *.log")
#if not options.dirty:
# os.system("rm *.aux *.log")
os.chdir(cwd)