diff --git a/Doc/source/conf.py b/Doc/source/conf.py index 56f22b68..5bdf8b5a 100644 --- a/Doc/source/conf.py +++ b/Doc/source/conf.py @@ -20,7 +20,7 @@ sys.path.insert(0, os.path.abspath('../../src/')) import gettext -gettext.install('pyromaths', unicode=1) +gettext.install('pyromaths') from pyromaths.Values import VERSION, COPYRIGHT_YEAR diff --git a/Doc/source/ecrire.rst b/Doc/source/ecrire.rst index 67c1c71e..256daf7e 100644 --- a/Doc/source/ecrire.rst +++ b/Doc/source/ecrire.rst @@ -58,7 +58,7 @@ Connaissances Créer un exercice pour Pyromaths nécessite de savoir utiliser un minimum : - :math:`LaTeX` ; -- Python (version 2) ; +- Python (version 3) ; - git. Une connaissance de la bibliothèque Python `jinja2 `__ est un plus, mais les bases s'apprennent rapidement et sont décrites plus loins dans ce document. diff --git a/Doc/source/pyromaths.cli.rst b/Doc/source/pyromaths.cli.rst index 773ab7b4..6a9c047b 100644 --- a/Doc/source/pyromaths.cli.rst +++ b/Doc/source/pyromaths.cli.rst @@ -21,26 +21,26 @@ Il y a deux manières d'appeler ce programme, qui sont équivalentes. .. code-block:: sh - python -m pyromaths.cli + python3 -m pyromaths.cli * En exécutant un fichier situé dans le répertoire `utils`. Le `PYTHONPATH` est automatiquement géré ; c'est utile si vous n'arrivez pas à le faire vous-même, ou si vous n'avez pas compris la phrase précédente. .. code-block:: sh - python utils/pyromaths-cli.py + python3 utils/pyromaths-cli.py Commandes disponibles ===================== -* Compilation d'un exercice (``python -m pyromaths.cli compile``) : +* Compilation d'un exercice (``python3 -m pyromaths.cli compile``) : Compile un exercice, et crée le PDF correspondant (énoncé et solution) dans le dossier courant. Cette commande est utile pour tester un exercice en cours de rédaction, plutôt que de passer par l'interface graphique. - Il est également possible de fournir des commandes à exécuter sur les fichiers LaTeX avant leur compilation. Ceci est utile pour déceler des erreurs de code LaTeX. Par exemple, la commande ``python -m pyromaths.cli compile -p more EXERCICE`` affiche le code LaTeX dans `more` avant compilation; la commande ``python -m pyromaths.cli compile -p vim EXERCICE`` édite le fichier avec `vim` avant compilation. Ceci peut aussi être utilisé (en attendant une solution plus propre) pour garder une copie du fichier LaTeX en cas d'erreur de compilation, pour pouvoir l'analyser, ainsi que le log : ``python -m pyromaths.cli compile -p 'cp {} exercices.tex' EXERCICE``. + Il est également possible de fournir des commandes à exécuter sur les fichiers LaTeX avant leur compilation. Ceci est utile pour déceler des erreurs de code LaTeX. Par exemple, la commande ``python3 -m pyromaths.cli compile -p more EXERCICE`` affiche le code LaTeX dans `more` avant compilation; la commande ``python3 -m pyromaths.cli compile -p vim EXERCICE`` édite le fichier avec `vim` avant compilation. Ceci peut aussi être utilisé (en attendant une solution plus propre) pour garder une copie du fichier LaTeX en cas d'erreur de compilation, pour pouvoir l'analyser, ainsi que le log : ``python3 -m pyromaths.cli compile -p 'cp {} exercices.tex' EXERCICE``. -* Liste des identifiants des exercices disponibles (``python -m pyromaths.cli ls``) : +* Liste des identifiants des exercices disponibles (``python3 -m pyromaths.cli ls``) : Affiche la liste des identifiants des exercices, pour retrouver facilement l'exercice en cours de travail. Plus d'informations sont données dans la partie :ref:`id_exos`. -* Test des exercices (``python -m pyromaths.cli test``) : +* Test des exercices (``python3 -m pyromaths.cli test``) : Voir la partie :ref:`pyrotests`. .. _id_exos: @@ -59,13 +59,13 @@ décrits comme ``exo_pythagore:4,6``, où : utilisée. La liste des exercices disponibles peut être obtenue avec la commande -``python -m pyromaths.cli ls``. +``python3 -m pyromaths.cli ls``. .. _pyrotests: -``python -m pyromaths.cli test`` -================================ +``python3 -m pyromaths.cli test`` +================================= Cet outil permet de mettre en œuvre des tests de non régression pour les exercices. @@ -82,7 +82,7 @@ exercice peut en valider un énoncé particulier. Plus tard, il sera possible de vérifier que l'exercice produit toujours exactement la même sortie. Cet outil est conçu de telle manière à ce que l'appel au module :mod:`unittest` -de Python (par exemple avec ``python -m unittest discover``) effectue tous ces +de Python (par exemple avec ``python3 -m unittest discover``) effectue tous ces tests. Commandes @@ -94,12 +94,12 @@ Description rapide Les commandes détaillées sont décrites ci-après. En voici une version simplifiée. -* Création (``python -m pyromaths.cli test create``), suppression des tests (``python -m pyromaths.cli test remove``) +* Création (``python3 -m pyromaths.cli test create``), suppression des tests (``python3 -m pyromaths.cli test remove``) -* Mise à jour des tests (``python -m pyromaths.cli test update``) : +* Mise à jour des tests (``python3 -m pyromaths.cli test update``) : Effectue les tests, et propose de mettre à jour les tests qui ont changé. Utile si le code LaTeX généré a changé, mais l'exercice reste valide pour autant. -* Exécution des tests (``python -m pyromaths.cli test check``) : +* Exécution des tests (``python3 -m pyromaths.cli test check``) : Effectue les tests. Les tests sont aussi exécutés lorsqu'``unittest`` est appelé. diff --git a/Doc/source/pyromaths.exemples.rst b/Doc/source/pyromaths.exemples.rst index fafbd7f3..96557960 100644 --- a/Doc/source/pyromaths.exemples.rst +++ b/Doc/source/pyromaths.exemples.rst @@ -94,7 +94,7 @@ Opérations mathématiques >>> repr(Fraction(2,5) * 4) Fraction(8, 5) -* Quotient (:func:`Fraction.__div__` et :func:`Fraction.__rdiv__`) +* Quotient (:func:`Fraction.__div__` et :func:`Fraction.__rtruediv__`) .. doctest:: fraction @@ -814,8 +814,8 @@ LaTeX .. doctest:: polynomedegre2 - >>> Poly2(2, 3, 4).print_signe("\leq") - 2x^2+3x+4 \leq 0 + >>> Poly2(2, 3, 4).print_signe("\leqslant") + 2x^2+3x+4 \leqslant 0 Conversion en LaTeX ------------------- diff --git a/NEWS b/NEWS index 8c006f59..9e61e204 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Version XX.XX +* Passage à Python3 + Version 18.06 * Nouvel exercice niveau terminale ES (spécialité) : Déterminer l'état stable d'un graphe probabiliste (en utilisant un système d'équations). * Nouvel exercice niveau terminale ES (spécialité) : Résoudre un système d'équations en utilisant les matrices. diff --git a/data/ex/tests/ArrondirNombreDecimal.0.answer b/data/ex/tests/ArrondirNombreDecimal.0.answer index 393b807b..5ffbe6f0 100644 --- a/data/ex/tests/ArrondirNombreDecimal.0.answer +++ b/data/ex/tests/ArrondirNombreDecimal.0.answer @@ -1,15 +1,15 @@ \exercice* \begin{enumerate} -\item L'encadrement de 845\,987 à la dizaine est :\par -845\,980 < 845\,987 < 845\,990\par -On en déduit que son arrondi à la dizaine par défaut est : 845\,980. -\item L'encadrement de 4\,263,73 au dixième est :\par -4\,263,7 < 4\,263,73 < 4\,263,8\par -On en déduit que son arrondi au dixième par défaut est : 4\,263,7. -\item L'encadrement de 51,616\,4 au millième est :\par -51,616 < 51,616\,4 < 51,617\par -On en déduit que son arrondi au millième par défaut est : 51,616. -\item L'encadrement de 78,596\,3 au millième est :\par -78,596 < 78,596\,3 < 78,597\par -On en déduit que son arrondi au millième est : 78,596. +\item L'encadrement de 514,947 au centième est :\par +514,94 < 514,947 < 514,95\par +On en déduit que son arrondi au centième est : 514,95. +\item L'encadrement de 6\,306,5 à l'unité est :\par +6\,306 < 6\,306,5 < 6\,307\par +On en déduit que son arrondi à l'unité par défaut est : 6\,306. +\item L'encadrement de 68\,013\,800 au millier est :\par +68\,013\,000 < 68\,013\,800 < 68\,014\,000\par +On en déduit que son arrondi au millier par défaut est : 68\,013\,000. +\item L'encadrement de 5\,407\,550 à la centaine est :\par +5\,407\,500 < 5\,407\,550 < 5\,407\,600\par +On en déduit que son arrondi à la centaine par excès est : 5\,407\,600. \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/ArrondirNombreDecimal.0.statement b/data/ex/tests/ArrondirNombreDecimal.0.statement index f1ce611c..7c60c136 100644 --- a/data/ex/tests/ArrondirNombreDecimal.0.statement +++ b/data/ex/tests/ArrondirNombreDecimal.0.statement @@ -1,7 +1,7 @@ \exercice \begin{enumerate} -\item Arrondir 845\,987 à la dizaine par défaut. -\item Arrondir 4\,263,73 au dixième par défaut. -\item Arrondir 51,616\,4 au millième par défaut. -\item Arrondir 78,596\,3 au millième. +\item Arrondir 514,947 au centième. +\item Arrondir 6\,306,5 à l'unité par défaut. +\item Arrondir 68\,013\,800 au millier par défaut. +\item Arrondir 5\,407\,550 à la centaine par excès. \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/BilanTrinomeSansDiscriminant.0.answer b/data/ex/tests/BilanTrinomeSansDiscriminant.0.answer index 93d92e6c..a5d27f90 100644 --- a/data/ex/tests/BilanTrinomeSansDiscriminant.0.answer +++ b/data/ex/tests/BilanTrinomeSansDiscriminant.0.answer @@ -1,43 +1,43 @@ \exercice* -On considère le trinôme du second degré $f: x\mapsto \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{70}$. +On considère le trinôme du second degré $f: x\mapsto \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{96}$. \begin{enumerate} \item \begin{enumerate} \item Soit $x\in\mathbb{R}$. Alors : \begin{align*} - \numprint{2} \,\left( x +\numprint{5} \right) \, \left( x -\numprint{7} \right) - &= \numprint{2} \,\left(x\times{} x +\numprint{5}\times{} x -\numprint{7}\times{} x +\numprint{5}\times{} \left(\numprint{-7}\right) \right) \\ - &= \numprint{2} \,\left(x^2 -\numprint{2}\,x -\numprint{35}\right) \\ - &= \numprint{2}\times{} x^2 +\numprint{2}\times{} \left(\numprint{-2}\,x\right) +\numprint{2}\times{} \left(\numprint{-35}\right) \\ - &= \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{70}\\ + \numprint{2} \,\left( x +\numprint{6} \right) \, \left( x -\numprint{8} \right) + &= \numprint{2} \,\left(x\times{} x +\numprint{6}\times{} x -\numprint{8}\times{} x +\numprint{6}\times{} \left(\numprint{-8}\right) \right) \\ + &= \numprint{2} \,\left(x^2 -\numprint{2}\,x -\numprint{48}\right) \\ + &= \numprint{2}\times{} x^2 +\numprint{2}\times{} \left(\numprint{-2}\,x\right) +\numprint{2}\times{} \left(\numprint{-48}\right) \\ + &= \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{96}\\ &= f\,(x) \end{align*} \item Soit $x\in\mathbb{R}$. Alors : \begin{align*} - \numprint{2}\,\left( x -\numprint{1} \right)^2 -\numprint{72} - &= \numprint{2}\,\left( x^2 -\numprint{2}\times{} \numprint{1} \times{} x + \numprint{1}^2\right) -\numprint{72}\\ - &= \numprint{2}\,\left( x^2 -\numprint{2}\,x + \numprint{1}\right) -\numprint{72}\\ - &= \numprint{2}\times{} x^2 +\numprint{2}\times{} \left(\numprint{-2}\,x\right) +\numprint{2}\times{} \numprint{1} -\numprint{72}\\ - &= \numprint{2}\,x^2 -\numprint{4}\,x +\numprint{2} -\numprint{72}\\ - &= \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{70}\\ + \numprint{2}\,\left( x -\numprint{1} \right)^2 -\numprint{98} + &= \numprint{2}\,\left( x^2 -\numprint{2}\times{} \numprint{1} \times{} x + \numprint{1}^2\right) -\numprint{98}\\ + &= \numprint{2}\,\left( x^2 -\numprint{2}\,x + \numprint{1}\right) -\numprint{98}\\ + &= \numprint{2}\times{} x^2 +\numprint{2}\times{} \left(\numprint{-2}\,x\right) +\numprint{2}\times{} \numprint{1} -\numprint{98}\\ + &= \numprint{2}\,x^2 -\numprint{4}\,x +\numprint{2} -\numprint{98}\\ + &= \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{96}\\ &= f\,(x) \end{align*} \end{enumerate} \item Résoudre les équations suivantes en choisissant la forme appropriée de $f$. \begin{enumerate} -\item En prenant la forme factorisée, l'équation $f\,(x)=0$ est équivalente à l'équation produit nul $\numprint{2}\,(x +\numprint{5} )\,(x -\numprint{7} ) = 0$. Donc : +\item En prenant la forme factorisée, l'équation $f\,(x)=0$ est équivalente à l'équation produit nul $\numprint{2}\,(x +\numprint{6} )\,(x -\numprint{8} ) = 0$. Donc : \begin{align*} -x +\numprint{5}=0 &\text{ ou } x -\numprint{7}=0 \\ -x=\numprint{-5} &\text{ ou } x=\numprint{7} +x +\numprint{6}=0 &\text{ ou } x -\numprint{8}=0 \\ +x=\numprint{-6} &\text{ ou } x=\numprint{8} \end{align*} -Il y a donc deux solutions : $\numprint{-5}$ et $\numprint{7}$. -\item $f\,(x)=\numprint{-70}$ On remarque que la forme développée contient la constante $\numprint{-70}$ : celles-ci devraient donc s'annuler, pour simplifier notre résolution. +Il y a donc deux solutions : $\numprint{-6}$ et $\numprint{8}$. +\item $f\,(x)=\numprint{-96}$ On remarque que la forme développée contient la constante $\numprint{-96}$ : celles-ci devraient donc s'annuler, pour simplifier notre résolution. \begin{align*} -f\,(x) &= \numprint{-70} \\ -\numprint{2}\,x^2 -\numprint{4}\,x -\numprint{70} &= \numprint{-70} \\ -\numprint{2}\,x^2 -\numprint{4}\,x -\numprint{70} +\numprint{70} &= \numprint{-70} +\numprint{70} \\ +f\,(x) &= \numprint{-96} \\ +\numprint{2}\,x^2 -\numprint{4}\,x -\numprint{96} &= \numprint{-96} \\ +\numprint{2}\,x^2 -\numprint{4}\,x -\numprint{96} +\numprint{96} &= \numprint{-96} +\numprint{96} \\ \numprint{2}\,x^2 -\numprint{4}\,x &= 0 \\ \end{align*} Nous pouvons maintenant factoriser le membre de gauche par $x$, ce qui nous donnera une équation produit nul. @@ -53,11 +53,11 @@ x =0 &\text{ ou } x = \frac{\numprint{4}}{\numprint{2}} \\ x =0 &\text{ ou } x = \numprint{2} \\ \end{align*} Il y a donc deux solutions : $x=0$ et $x=\numprint{2}$. -\item $f\,(x)=\numprint{-72}$ On remarque que la forme canonique contient la constante $\numprint{-72}$ : en l'utilisant, elles devraient se simplifier. +\item $f\,(x)=\numprint{-98}$ On remarque que la forme canonique contient la constante $\numprint{-98}$ : en l'utilisant, elles devraient se simplifier. \begin{align*} -f\,(x) &= \numprint{-72} \\ -\numprint{2} \,\left( x -\numprint{1} \right)^2 -\numprint{72} &= \numprint{-72}\\ -\numprint{2} \,\left( x -\numprint{1} \right)^2 -\numprint{72} +\numprint{72} &= \numprint{-72} +\numprint{72}\\ +f\,(x) &= \numprint{-98} \\ +\numprint{2} \,\left( x -\numprint{1} \right)^2 -\numprint{98} &= \numprint{-98}\\ +\numprint{2} \,\left( x -\numprint{1} \right)^2 -\numprint{98} +\numprint{98} &= \numprint{-98} +\numprint{98}\\ \numprint{2} \,\left( x -\numprint{1} \right)^2 &= 0\\ \left( x -\numprint{1} \right)^2 &= 0\\ \end{align*} @@ -75,21 +75,21 @@ Il y a donc une unique solution $x=\numprint{1}$. donc la fonction est décroissante puis croissante . De plus, l'absisse du sommet est $-\frac{\numprint{-4}}{2\times{}\numprint{2}}$, soit $\numprint{1}$, et -$f\,( \numprint{1} )=\numprint{2}\times{}\numprint{1}^2 -\numprint{4}\times{} \numprint{1} -\numprint{70}=\numprint{-72}$. +$f\,( \numprint{1} )=\numprint{2}\times{}\numprint{1}^2 -\numprint{4}\times{} \numprint{1} -\numprint{96}=\numprint{-98}$. Le tableau de variations est donc : \begin{center} \begin{tikzpicture} \tkzTabInit[espcl=2.5] {$x$/1, $f\,(x)$/1.5} {$-\infty$, $\numprint{1}$, $+\infty$} - \tkzTabVar{+/, -/$\numprint{-72}$/, +/} + \tkzTabVar{+/, -/$\numprint{-98}$/, +/} \end{tikzpicture} \end{center} -\item \emph{Dresser le tableau de signes de $f$.} Construisons un tableau de signes en utilisant la forme factorisée $f\,(x)=\numprint{2} \,\left(x +\numprint{5}\right) \, \left(x -\numprint{7}\right)$. +\item \emph{Dresser le tableau de signes de $f$.} Construisons un tableau de signes en utilisant la forme factorisée $f\,(x)=\numprint{2} \,\left(x +\numprint{6}\right) \, \left(x -\numprint{8}\right)$. \begin{itemize} -\item Le premier facteur $x +\numprint{5}$ est une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{5}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{5}}{1}=\numprint{-5}$. -\item Le second facteur $x -\numprint{7}$ est aussi une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{-7}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{-7}}{1}=\numprint{7}$. +\item Le premier facteur $x +\numprint{6}$ est une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{6}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{6}}{1}=\numprint{-6}$. +\item Le second facteur $x -\numprint{8}$ est aussi une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{-8}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{-8}}{1}=\numprint{8}$. \end{itemize} \begin{center} \begin{tikzpicture} @@ -97,11 +97,11 @@ Le tableau de variations est donc : { $x$/1, $\numprint{2}$/1, - $x +\numprint{5}$/1, - $x -\numprint{7}$/1, - $f\,(x)=\numprint{2}\,\left( x +\numprint{5} \right)\,\left( x -\numprint{7} \right)$/1.5 + $x +\numprint{6}$/1, + $x -\numprint{8}$/1, + $f\,(x)=\numprint{2}\,\left( x +\numprint{6} \right)\,\left( x -\numprint{8} \right)$/1.5 } - {$-\infty$, $\numprint{-5}$, $\numprint{7}$, $+\infty$} + {$-\infty$, $\numprint{-6}$, $\numprint{8}$, $+\infty$} \tkzTabLine{, +, t, +, t, +} \tkzTabLine{, -, z, +, t, +} \tkzTabLine{, -, t, -, z, +} @@ -114,9 +114,9 @@ Le tableau de variations est donc : \item \emph{Résoudre $f\,(x)\geqslant0$.} En regardant la dernière ligne du tableau de signes, on observe que $f$ est positive sur les premier et dernier intervalles . Les solutions sont donc : - \[ x\in\interval[open left, scaled]{-\infty}{\numprint{-5}} \cup \interval[open right, scaled]{\numprint{7}}{+\infty} \] + \[ x\in\interval[open left, scaled]{-\infty}{\numprint{-6}} \cup \interval[open right, scaled]{\numprint{8}}{+\infty} \] \item \emph{Quel est l'extremum de $f$ ? Est-ce un maximum ou un minimum ? Pour quelle valeur de $x$ est-il atteint ?} On lit sur le tableau de variations que la plus - petite valeur prise par $f$ est $\numprint{-72}$. Le - minimum de $f$ est donc $\numprint{-72}$, et il est atteint pour $x=\numprint{1}$. + petite valeur prise par $f$ est $\numprint{-98}$. Le + minimum de $f$ est donc $\numprint{-98}$, et il est atteint pour $x=\numprint{1}$. \end{enumerate} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/BilanTrinomeSansDiscriminant.0.statement b/data/ex/tests/BilanTrinomeSansDiscriminant.0.statement index c2be40ab..7e15d0a9 100644 --- a/data/ex/tests/BilanTrinomeSansDiscriminant.0.statement +++ b/data/ex/tests/BilanTrinomeSansDiscriminant.0.statement @@ -1,17 +1,17 @@ \exercice -On considère le trinôme du second degré $f: x\mapsto \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{70}$. +On considère le trinôme du second degré $f: x\mapsto \numprint{2}\,x^2 -\numprint{4}\,x -\numprint{96}$. \begin{enumerate} \item \begin{enumerate} - \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{2} \,\left( x +\numprint{5} \right) \, \left( x -\numprint{7} \right) $. - \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{2} \,\left( x -\numprint{1} \right)^2 -\numprint{72}$. + \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{2} \,\left( x +\numprint{6} \right) \, \left( x -\numprint{8} \right) $. + \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{2} \,\left( x -\numprint{1} \right)^2 -\numprint{98}$. \end{enumerate} \item Résoudre les équations suivantes en choisissant la forme appropriée de $f$. \begin{enumerate} \item $f\,(x)=0$ -\item $f\,(x)=\numprint{-70}$ -\item $f\,(x)=\numprint{-72}$ +\item $f\,(x)=\numprint{-96}$ +\item $f\,(x)=\numprint{-98}$ \end{enumerate} \item \begin{enumerate} diff --git a/data/ex/tests/BilanTrinomeSansDiscriminant.1.answer b/data/ex/tests/BilanTrinomeSansDiscriminant.1.answer index e4d8ee30..8efdf5d0 100644 --- a/data/ex/tests/BilanTrinomeSansDiscriminant.1.answer +++ b/data/ex/tests/BilanTrinomeSansDiscriminant.1.answer @@ -1,72 +1,72 @@ \exercice* -On considère le trinôme du second degré $f: x\mapsto \numprint{-2}\,x^2 -\numprint{6}\,x +\numprint{80}$. +On considère le trinôme du second degré $f: x\mapsto \numprint{-0.5}\,x^2 +\numprint{8.5}\,x -\numprint{21}$. \begin{enumerate} \item \begin{enumerate} \item Soit $x\in\mathbb{R}$. Alors : \begin{align*} - \numprint{-2} \,\left( x -\numprint{5} \right) \, \left( x +\numprint{8} \right) - &= \numprint{-2} \,\left(x\times{} x -\numprint{5}\times{} x +\numprint{8}\times{} x -\numprint{5}\times{} \numprint{8} \right) \\ - &= \numprint{-2} \,\left(x^2 +\numprint{3}\,x -\numprint{40}\right) \\ - &= \numprint{-2}\times{} x^2 -\numprint{2}\times{} \numprint{3}\,x -\numprint{2}\times{} \left(\numprint{-40}\right) \\ - &= \numprint{-2}\,x^2 -\numprint{6}\,x +\numprint{80}\\ + \numprint{-0.5} \,\left( x -\numprint{3} \right) \, \left( x -\numprint{14} \right) + &= \numprint{-0.5} \,\left(x\times{} x -\numprint{3}\times{} x -\numprint{14}\times{} x -\numprint{3}\times{} \left(\numprint{-14}\right) \right) \\ + &= \numprint{-0.5} \,\left(x^2 -\numprint{17}\,x +\numprint{42}\right) \\ + &= \numprint{-0.5}\times{} x^2 -\numprint{0.5}\times{} \left(\numprint{-17}\,x\right) -\numprint{0.5}\times{} \numprint{42} \\ + &= \numprint{-0.5}\,x^2 +\numprint{8.5}\,x -\numprint{21}\\ &= f\,(x) \end{align*} \item Soit $x\in\mathbb{R}$. Alors : \begin{align*} - \numprint{-2}\,\left( x +\numprint{1.5} \right)^2 +\numprint{84.5} - &= \numprint{-2}\,\left( x^2 +\numprint{2}\times{} \numprint{1.5} \times{} x + \numprint{1.5}^2\right) +\numprint{84.5}\\ - &= \numprint{-2}\,\left( x^2 +\numprint{3}\,x + \numprint{2.25}\right) +\numprint{84.5}\\ - &= \numprint{-2}\times{} x^2 -\numprint{2}\times{} \numprint{3}\,x -\numprint{2}\times{} \numprint{2.25} +\numprint{84.5}\\ - &= \numprint{-2}\,x^2 -\numprint{6}\,x -\numprint{4.5} +\numprint{84.5}\\ - &= \numprint{-2}\,x^2 -\numprint{6}\,x +\numprint{80}\\ + \numprint{-0.5}\,\left( x -\numprint{8.5} \right)^2 +\numprint{15.125} + &= \numprint{-0.5}\,\left( x^2 -\numprint{2}\times{} \numprint{8.5} \times{} x + \numprint{8.5}^2\right) +\numprint{15.125}\\ + &= \numprint{-0.5}\,\left( x^2 -\numprint{17}\,x + \numprint{72.25}\right) +\numprint{15.125}\\ + &= \numprint{-0.5}\times{} x^2 -\numprint{0.5}\times{} \left(\numprint{-17}\,x\right) -\numprint{0.5}\times{} \numprint{72.25} +\numprint{15.125}\\ + &= \numprint{-0.5}\,x^2 +\numprint{8.5}\,x -\numprint{36.125} +\numprint{15.125}\\ + &= \numprint{-0.5}\,x^2 +\numprint{8.5}\,x -\numprint{21}\\ &= f\,(x) \end{align*} \end{enumerate} \item Résoudre les équations suivantes en choisissant la forme appropriée de $f$. \begin{enumerate} -\item En prenant la forme factorisée, l'équation $f\,(x)=0$ est équivalente à l'équation produit nul $\numprint{-2}\,(x -\numprint{5} )\,(x +\numprint{8} ) = 0$. Donc : +\item En prenant la forme factorisée, l'équation $f\,(x)=0$ est équivalente à l'équation produit nul $\numprint{-0.5}\,(x -\numprint{3} )\,(x -\numprint{14} ) = 0$. Donc : \begin{align*} -x -\numprint{5}=0 &\text{ ou } x +\numprint{8}=0 \\ -x=\numprint{5} &\text{ ou } x=\numprint{-8} +x -\numprint{3}=0 &\text{ ou } x -\numprint{14}=0 \\ +x=\numprint{3} &\text{ ou } x=\numprint{14} \end{align*} -Il y a donc deux solutions : $\numprint{5}$ et $\numprint{-8}$. -\item $f\,(x)=\numprint{80}$ On remarque que la forme développée contient la constante $\numprint{80}$ : celles-ci devraient donc s'annuler, pour simplifier notre résolution. +Il y a donc deux solutions : $\numprint{3}$ et $\numprint{14}$. +\item $f\,(x)=\numprint{-21}$ On remarque que la forme développée contient la constante $\numprint{-21}$ : celles-ci devraient donc s'annuler, pour simplifier notre résolution. \begin{align*} -f\,(x) &= \numprint{80} \\ -\numprint{-2}\,x^2 -\numprint{6}\,x +\numprint{80} &= \numprint{80} \\ -\numprint{-2}\,x^2 -\numprint{6}\,x +\numprint{80} -\numprint{80} &= \numprint{80} -\numprint{80} \\ -\numprint{-2}\,x^2 -\numprint{6}\,x &= 0 \\ +f\,(x) &= \numprint{-21} \\ +\numprint{-0.5}\,x^2 +\numprint{8.5}\,x -\numprint{21} &= \numprint{-21} \\ +\numprint{-0.5}\,x^2 +\numprint{8.5}\,x -\numprint{21} +\numprint{21} &= \numprint{-21} +\numprint{21} \\ +\numprint{-0.5}\,x^2 +\numprint{8.5}\,x &= 0 \\ \end{align*} Nous pouvons maintenant factoriser le membre de gauche par $x$, ce qui nous donnera une équation produit nul. \begin{align*} -\numprint{-2}\,x^2 -\numprint{6}\,x &= 0 \\ -\numprint{-2}\,x\times{} x -\numprint{6}\times{} x &= 0 \\ -x\,\left( \numprint{-2}\,x -\numprint{6} \right) &= 0 \\ +\numprint{-0.5}\,x^2 +\numprint{8.5}\,x &= 0 \\ +\numprint{-0.5}\,x\times{} x +\numprint{8.5}\times{} x &= 0 \\ +x\,\left( \numprint{-0.5}\,x +\numprint{8.5} \right) &= 0 \\ \end{align*} \begin{align*} -x =0 &\text{ ou } \numprint{-2}\,x -\numprint{6}=0 \\ -x =0 &\text{ ou } \numprint{-2}\,x =\numprint{6} \\ -x =0 &\text{ ou } x = \frac{\numprint{6}}{\numprint{-2}} \\ -x =0 &\text{ ou } x = \numprint{-3} \\ +x =0 &\text{ ou } \numprint{-0.5}\,x +\numprint{8.5}=0 \\ +x =0 &\text{ ou } \numprint{-0.5}\,x =\numprint{-8.5} \\ +x =0 &\text{ ou } x = \frac{\numprint{-8.5}}{\numprint{-0.5}} \\ +x =0 &\text{ ou } x = \numprint{17} \\ \end{align*} -Il y a donc deux solutions : $x=0$ et $x=\numprint{-3}$. -\item $f\,(x)=\numprint{84.5}$ On remarque que la forme canonique contient la constante $\numprint{84.5}$ : en l'utilisant, elles devraient se simplifier. +Il y a donc deux solutions : $x=0$ et $x=\numprint{17}$. +\item $f\,(x)=\numprint{15.125}$ On remarque que la forme canonique contient la constante $\numprint{15.125}$ : en l'utilisant, elles devraient se simplifier. \begin{align*} -f\,(x) &= \numprint{84.5} \\ -\numprint{-2} \,\left( x +\numprint{1.5} \right)^2 +\numprint{84.5} &= \numprint{84.5}\\ -\numprint{-2} \,\left( x +\numprint{1.5} \right)^2 +\numprint{84.5} -\numprint{84.5} &= \numprint{84.5} -\numprint{84.5}\\ -\numprint{-2} \,\left( x +\numprint{1.5} \right)^2 &= 0\\ -\left( x +\numprint{1.5} \right)^2 &= 0\\ +f\,(x) &= \numprint{15.125} \\ +\numprint{-0.5} \,\left( x -\numprint{8.5} \right)^2 +\numprint{15.125} &= \numprint{15.125}\\ +\numprint{-0.5} \,\left( x -\numprint{8.5} \right)^2 +\numprint{15.125} -\numprint{15.125} &= \numprint{15.125} -\numprint{15.125}\\ +\numprint{-0.5} \,\left( x -\numprint{8.5} \right)^2 &= 0\\ +\left( x -\numprint{8.5} \right)^2 &= 0\\ \end{align*} Or $0$ est le seul nombre dont le carré est nul, donc l'équation précédente est équivalente à : \begin{align*} -x +\numprint{1.5} &= 0\\ -x &= \numprint{-1.5} \\ +x -\numprint{8.5} &= 0\\ +x &= \numprint{8.5} \\ \end{align*} -Il y a donc une unique solution $x=\numprint{-1.5}$. +Il y a donc une unique solution $x=\numprint{8.5}$. \end{enumerate} \item \begin{enumerate} @@ -74,37 +74,37 @@ Il y a donc une unique solution $x=\numprint{-1.5}$. négatif , donc la fonction est croissante puis décroissante . -De plus, l'absisse du sommet est $-\frac{\numprint{-6}}{2\times{}\left(\numprint{-2}\right)}$, soit $\numprint{-1.5}$, et -$f\,( \numprint{-1.5} )=\numprint{-2}\times{}\left(\numprint{-1.5}\right)^2 -\numprint{6}\times{} \left(\numprint{-1.5}\right) +\numprint{80}=\numprint{84.5}$. +De plus, l'absisse du sommet est $-\frac{\numprint{8.5}}{2\times{}\left(\numprint{-0.5}\right)}$, soit $\numprint{8.5}$, et +$f\,( \numprint{8.5} )=\numprint{-0.5}\times{}\numprint{8.5}^2 +\numprint{8.5}\times{} \numprint{8.5} -\numprint{21}=\numprint{15.125}$. Le tableau de variations est donc : \begin{center} \begin{tikzpicture} \tkzTabInit[espcl=2.5] {$x$/1, $f\,(x)$/1.5} - {$-\infty$, $\numprint{-1.5}$, $+\infty$} - \tkzTabVar{-/, +/$\numprint{84.5}$/, -/} + {$-\infty$, $\numprint{8.5}$, $+\infty$} + \tkzTabVar{-/, +/$\numprint{15.125}$/, -/} \end{tikzpicture} \end{center} -\item \emph{Dresser le tableau de signes de $f$.} Construisons un tableau de signes en utilisant la forme factorisée $f\,(x)=\numprint{-2} \,\left(x -\numprint{5}\right) \, \left(x +\numprint{8}\right)$. +\item \emph{Dresser le tableau de signes de $f$.} Construisons un tableau de signes en utilisant la forme factorisée $f\,(x)=\numprint{-0.5} \,\left(x -\numprint{3}\right) \, \left(x -\numprint{14}\right)$. \begin{itemize} -\item Le premier facteur $x -\numprint{5}$ est une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{-5}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{-5}}{1}=\numprint{5}$. -\item Le second facteur $x +\numprint{8}$ est aussi une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{8}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{8}}{1}=\numprint{-8}$. +\item Le premier facteur $x -\numprint{3}$ est une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{-3}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{-3}}{1}=\numprint{3}$. +\item Le second facteur $x -\numprint{14}$ est aussi une fonction affine, de coefficient directeur $a=1$ positif, et d'ordonnée à l'origine $b=\numprint{-14}$. Elle est donc négative, puis positive, et change de signe en $-\frac{b}{a}=-\frac{\numprint{-14}}{1}=\numprint{14}$. \end{itemize} \begin{center} \begin{tikzpicture} \tkzTabInit[lgt=4, espcl=2.5] { $x$/1, - $\numprint{-2}$/1, - $x -\numprint{5}$/1, - $x +\numprint{8}$/1, - $f\,(x)=\numprint{-2}\,\left( x -\numprint{5} \right)\,\left( x +\numprint{8} \right)$/1.5 + $\numprint{-0.5}$/1, + $x -\numprint{3}$/1, + $x -\numprint{14}$/1, + $f\,(x)=\numprint{-0.5}\,\left( x -\numprint{3} \right)\,\left( x -\numprint{14} \right)$/1.5 } - {$-\infty$, $\numprint{-8}$, $\numprint{5}$, $+\infty$} + {$-\infty$, $\numprint{3}$, $\numprint{14}$, $+\infty$} \tkzTabLine{, -, t, -, t, -} - \tkzTabLine{, -, t, -, z, +} \tkzTabLine{, -, z, +, t, +} + \tkzTabLine{, -, t, -, z, +} \tkzTabLine{, -, z, +, z, -} \end{tikzpicture} \end{center} @@ -114,9 +114,9 @@ Le tableau de variations est donc : \item \emph{Résoudre $f\,(x)\geqslant0$.} En regardant la dernière ligne du tableau de signes, on observe que $f$ est positive sur l'intervalle central . Les solutions sont donc : - \[ x\in\interval[scaled]{\numprint{-8}}{\numprint{5}} \] + \[ x\in\interval[scaled]{\numprint{3}}{\numprint{14}} \] \item \emph{Quel est l'extremum de $f$ ? Est-ce un maximum ou un minimum ? Pour quelle valeur de $x$ est-il atteint ?} On lit sur le tableau de variations que la plus - grande valeur prise par $f$ est $\numprint{84.5}$. Le - maximum de $f$ est donc $\numprint{84.5}$, et il est atteint pour $x=\numprint{-1.5}$. + grande valeur prise par $f$ est $\numprint{15.125}$. Le + maximum de $f$ est donc $\numprint{15.125}$, et il est atteint pour $x=\numprint{8.5}$. \end{enumerate} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/BilanTrinomeSansDiscriminant.1.statement b/data/ex/tests/BilanTrinomeSansDiscriminant.1.statement index ec799a4e..3c5f3f93 100644 --- a/data/ex/tests/BilanTrinomeSansDiscriminant.1.statement +++ b/data/ex/tests/BilanTrinomeSansDiscriminant.1.statement @@ -1,17 +1,17 @@ \exercice -On considère le trinôme du second degré $f: x\mapsto \numprint{-2}\,x^2 -\numprint{6}\,x +\numprint{80}$. +On considère le trinôme du second degré $f: x\mapsto \numprint{-0.5}\,x^2 +\numprint{8.5}\,x -\numprint{21}$. \begin{enumerate} \item \begin{enumerate} - \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{-2} \,\left( x -\numprint{5} \right) \, \left( x +\numprint{8} \right) $. - \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{-2} \,\left( x +\numprint{1.5} \right)^2 +\numprint{84.5}$. + \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{-0.5} \,\left( x -\numprint{3} \right) \, \left( x -\numprint{14} \right) $. + \item Montrer que pour tout $x\in\mathbb{R}$, on a : $f\,(x)=\numprint{-0.5} \,\left( x -\numprint{8.5} \right)^2 +\numprint{15.125}$. \end{enumerate} \item Résoudre les équations suivantes en choisissant la forme appropriée de $f$. \begin{enumerate} \item $f\,(x)=0$ -\item $f\,(x)=\numprint{80}$ -\item $f\,(x)=\numprint{84.5}$ +\item $f\,(x)=\numprint{-21}$ +\item $f\,(x)=\numprint{15.125}$ \end{enumerate} \item \begin{enumerate} diff --git a/data/ex/tests/ClasserNombres.0.answer b/data/ex/tests/ClasserNombres.0.answer index 07405118..4c8b5aef 100644 --- a/data/ex/tests/ClasserNombres.0.answer +++ b/data/ex/tests/ClasserNombres.0.answer @@ -1,9 +1,9 @@ \exercice* \begin{enumerate} \item Classer les nombres suivants dans l'ordre décroissant.\par -8,7 \kern1cm ; \kern1cm 8,43 \kern1cm ; \kern1cm 3,4 \kern1cm ; \kern1cm 8,548\par -8,7 \kern1cm \textgreater \kern1cm 8,548 \kern1cm \textgreater \kern1cm 8,43 \kern1cm \textgreater \kern1cm 3,4 -\item Classer les nombres suivants dans l'ordre décroissant.\par -7,39 \kern1cm ; \kern1cm 7,6 \kern1cm ; \kern1cm 7,989 \kern1cm ; \kern1cm 3,7\par -7,989 \kern1cm \textgreater \kern1cm 7,6 \kern1cm \textgreater \kern1cm 7,39 \kern1cm \textgreater \kern1cm 3,7 +6,149\,999\,999\,999\,999\,5 \kern1cm ; \kern1cm 6,7 \kern1cm ; \kern1cm 4,7 \kern1cm ; \kern1cm 6,987\par +6,987 \kern1cm \textgreater \kern1cm 6,7 \kern1cm \textgreater \kern1cm 6,149\,999\,999\,999\,999\,5 \kern1cm \textgreater \kern1cm 4,7 +\item Classer les nombres suivants dans l'ordre croissant.\par +1,1 \kern1cm ; \kern1cm 4,3 \kern1cm ; \kern1cm 4,25 \kern1cm ; \kern1cm 4,935\,000\,000\,000\,000\,5\par +1,1 \kern1cm \textless \kern1cm 4,25 \kern1cm \textless \kern1cm 4,3 \kern1cm \textless \kern1cm 4,935\,000\,000\,000\,000\,5 \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/ClasserNombres.0.statement b/data/ex/tests/ClasserNombres.0.statement index 627f45a7..4ab64752 100644 --- a/data/ex/tests/ClasserNombres.0.statement +++ b/data/ex/tests/ClasserNombres.0.statement @@ -1,7 +1,7 @@ \exercice \begin{enumerate} \item Classer les nombres suivants dans l'ordre décroissant.\par -8,7 \kern1cm ; \kern1cm 8,43 \kern1cm ; \kern1cm 3,4 \kern1cm ; \kern1cm 8,548 -\item Classer les nombres suivants dans l'ordre décroissant.\par -7,39 \kern1cm ; \kern1cm 7,6 \kern1cm ; \kern1cm 7,989 \kern1cm ; \kern1cm 3,7 +6,149\,999\,999\,999\,999\,5 \kern1cm ; \kern1cm 6,7 \kern1cm ; \kern1cm 4,7 \kern1cm ; \kern1cm 6,987 +\item Classer les nombres suivants dans l'ordre croissant.\par +1,1 \kern1cm ; \kern1cm 4,3 \kern1cm ; \kern1cm 4,25 \kern1cm ; \kern1cm 4,935\,000\,000\,000\,000\,5 \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/ConstruireZigZag.0.answer b/data/ex/tests/ConstruireZigZag.0.answer index e3b25963..8e4354c8 100644 --- a/data/ex/tests/ConstruireZigZag.0.answer +++ b/data/ex/tests/ConstruireZigZag.0.answer @@ -1,27 +1,27 @@ \exercice* Construire sur la figure ci-dessous les points $C$, $D$, $E$, $F$ et $G$ pour obtenir un zigzag tel que :\par -$\widehat{ABC}=67\degres \qquad \widehat{BCD}=170\degres \qquad \widehat{CDE}=178\degres \qquad \widehat{DEF}=87\degres \qquad \widehat{EFG}=52\degres \qquad $\par +$\widehat{ABC}=24\degres \qquad \widehat{BCD}=50\degres \qquad \widehat{CDE}=117\degres \qquad \widehat{DEF}=163\degres \qquad \widehat{EFG}=122\degres \qquad $\par Quand le travail est fait avec une bonne précision, les droites $(AF)$ et $(BG)$ se coupent au c\oe ur de la cible. \begin{center} \fbox{ \begin{pspicture}(-.4,-.4)(16.4, 5.5) -\pstGeonode[PosAngle=-92.00, PointSymbol=x](0.20, 0.20){A} \pscircle[linecolor=Gray](7.72, 2.61){0.1} -\pscircle[linecolor=Gray](7.72, 2.61){0.2} -\pscircle[linecolor=Gray](7.72, 2.61){0.3} -\pscircle[linecolor=Gray](7.72, 2.61){0.4} -\pstGeonode[PosAngle=-238.50](0.34, 4.20){B} \pstSegmentMark{A}{B} -\pstGeonode[PosAngle=-110.00](3.96, 2.51){C} \pstSegmentMark{B}{C} -\pstGeonode[PosAngle=-286.00](7.83, 1.47){D} \pstSegmentMark{C}{D} -\pstGeonode[PosAngle=-60.50](11.65, 0.30){E} \pstSegmentMark{D}{E} -\pstGeonode[PosAngle=-258.00](12.62, 4.18){F} \pstSegmentMark{E}{F} -\pstGeonode[PosAngle=-52.00, PointSymbol=x](15.08, 1.03){G} \pstSegmentMark{F}{G} -\pstMarkAngle{A}{B}{C}{67\degres} -\pstMarkAngle{D}{C}{B}{170\degres} -\pstMarkAngle{C}{D}{E}{178\degres} -\pstMarkAngle{F}{E}{D}{87\degres} -\pstMarkAngle{E}{F}{G}{52\degres} +\pstGeonode[PosAngle=-94.00, PointSymbol=x](0.20, 0.20){A} \pscircle[linecolor=Gray](7.53, 3.03){0.1} +\pscircle[linecolor=Gray](7.53, 3.03){0.2} +\pscircle[linecolor=Gray](7.53, 3.03){0.3} +\pscircle[linecolor=Gray](7.53, 3.03){0.4} +\pstGeonode[PosAngle=-262.00](0.48, 4.19){B} \pstSegmentMark{A}{B} +\pstGeonode[PosAngle=-95.00](1.85, 0.43){C} \pstSegmentMark{B}{C} +\pstGeonode[PosAngle=-241.50](3.85, 3.90){D} \pstSegmentMark{C}{D} +\pstGeonode[PosAngle=-84.50](7.84, 3.69){E} \pstSegmentMark{D}{E} +\pstGeonode[PosAngle=-285.00](11.72, 4.65){F} \pstSegmentMark{E}{F} +\pstGeonode[PosAngle=-44.00, PointSymbol=x](14.60, 1.88){G} \pstSegmentMark{F}{G} +\pstMarkAngle{A}{B}{C}{24\degres} +\pstMarkAngle{D}{C}{B}{50\degres} +\pstMarkAngle{C}{D}{E}{117\degres} +\pstMarkAngle{F}{E}{D}{163\degres} +\pstMarkAngle{E}{F}{G}{122\degres} \psline[linestyle=dotted](B)(G) \psline[linestyle=dotted](A)(F) \end{pspicture} } diff --git a/data/ex/tests/ConstruireZigZag.0.statement b/data/ex/tests/ConstruireZigZag.0.statement index 3a5215aa..a2da4b83 100644 --- a/data/ex/tests/ConstruireZigZag.0.statement +++ b/data/ex/tests/ConstruireZigZag.0.statement @@ -35,18 +35,18 @@ Voici deux exemples de zigzags :\par \end{pspicture}\par \psset{unit=1cm} Construire sur la figure ci-dessous les points $C$, $D$, $E$, $F$ et $G$ pour obtenir un zigzag tel que :\par -$\widehat{ABC}=67\degres \qquad \widehat{BCD}=170\degres \qquad \widehat{CDE}=178\degres \qquad \widehat{DEF}=87\degres \qquad \widehat{EFG}=52\degres \qquad $\par +$\widehat{ABC}=24\degres \qquad \widehat{BCD}=50\degres \qquad \widehat{CDE}=117\degres \qquad \widehat{DEF}=163\degres \qquad \widehat{EFG}=122\degres \qquad $\par Quand le travail est fait avec une bonne précision, les droites $(AF)$ et $(BG)$ se coupent au c\oe ur de la cible. \begin{center} \fbox{ \begin{pspicture}(-.4,-.4)(16.4, 5.5) -\pstGeonode[PosAngle=-92.00, PointSymbol=x](0.20, 0.20){A} \pstGeonode[PosAngle=-171.50, PointSymbol=x](0.34, 4.20){B} \pstSegmentMark{A}{B} -\pscircle[linecolor=Gray](7.72, 2.61){0.1} -\pscircle[linecolor=Gray](7.72, 2.61){0.2} -\pscircle[linecolor=Gray](7.72, 2.61){0.3} -\pscircle[linecolor=Gray](7.72, 2.61){0.4} +\pstGeonode[PosAngle=-94.00, PointSymbol=x](0.20, 0.20){A} \pstGeonode[PosAngle=-238.00, PointSymbol=x](0.48, 4.19){B} \pstSegmentMark{A}{B} +\pscircle[linecolor=Gray](7.53, 3.03){0.1} +\pscircle[linecolor=Gray](7.53, 3.03){0.2} +\pscircle[linecolor=Gray](7.53, 3.03){0.3} +\pscircle[linecolor=Gray](7.53, 3.03){0.4} \end{pspicture} } diff --git a/data/ex/tests/Decomposition.0.answer b/data/ex/tests/Decomposition.0.answer index 79e5d5ee..71487b74 100644 --- a/data/ex/tests/Decomposition.0.answer +++ b/data/ex/tests/Decomposition.0.answer @@ -2,11 +2,11 @@ Compléter avec un nombre décimal : \begin{multicols}{2}\noindent \begin{enumerate} -\item $7\times \cfrac{1}{100} + 3\times 10 + 4\times 1 = 34{,}07$ -\item $3\times \cfrac{1}{100} + 6\times 10 + 5\times \cfrac{1}{1\,000} = 60{,}035$ -\item $7\times 100 + 3\times \cfrac{1}{10} + 9\times \cfrac{1}{1\,000} = 700{,}309$ -\item $9\times \cfrac{1}{100} + 7\times 100 + 7\times \cfrac{1}{1\,000} = 700{,}097$ -\item $1\times 1 + 6\times 10 + 9\times \cfrac{1}{1\,000} = 61{,}009$ -\item $8\times 1 + 8\times 100 + 1\times \cfrac{1}{10} = 808{,}1$ +\item $7\times \cfrac{1}{1\,000} + 1\times 1 + 9\times 10 = 91{,}007$ +\item $7\times 1 + 8\times 10 + 4\times \cfrac{1}{10} = 87{,}4$ +\item $3\times \cfrac{1}{10} + 3\times 10 + 5\times 1\,000 = 5\,030{,}3$ +\item $3\times \cfrac{1}{10} + 2\times 10 + 6\times 1\,000 = 6\,020{,}3$ +\item $9\times 1 + 6\times 1\,000 + 6\times \cfrac{1}{100} = 6\,009{,}06$ +\item $4\times \cfrac{1}{10} + 8\times \cfrac{1}{100} + 9\times 1 = 9{,}48$ \end{enumerate} \end{multicols} \ No newline at end of file diff --git a/data/ex/tests/Decomposition.0.statement b/data/ex/tests/Decomposition.0.statement index 14550c6b..e6e19168 100644 --- a/data/ex/tests/Decomposition.0.statement +++ b/data/ex/tests/Decomposition.0.statement @@ -2,11 +2,11 @@ Compléter avec un nombre décimal : \begin{multicols}{2}\noindent \begin{enumerate} -\item $7\times \cfrac{1}{100} + 3\times 10 + 4\times 1 = \dotfill$ -\item $3\times \cfrac{1}{100} + 6\times 10 + 5\times \cfrac{1}{1\,000} = \dotfill$ -\item $7\times 100 + 3\times \cfrac{1}{10} + 9\times \cfrac{1}{1\,000} = \dotfill$ -\item $9\times \cfrac{1}{100} + 7\times 100 + 7\times \cfrac{1}{1\,000} = \dotfill$ -\item $1\times 1 + 6\times 10 + 9\times \cfrac{1}{1\,000} = \dotfill$ -\item $8\times 1 + 8\times 100 + 1\times \cfrac{1}{10} = \dotfill$ +\item $7\times \cfrac{1}{1\,000} + 1\times 1 + 9\times 10 = \dotfill$ +\item $7\times 1 + 8\times 10 + 4\times \cfrac{1}{10} = \dotfill$ +\item $3\times \cfrac{1}{10} + 3\times 10 + 5\times 1\,000 = \dotfill$ +\item $3\times \cfrac{1}{10} + 2\times 10 + 6\times 1\,000 = \dotfill$ +\item $9\times 1 + 6\times 1\,000 + 6\times \cfrac{1}{100} = \dotfill$ +\item $4\times \cfrac{1}{10} + 8\times \cfrac{1}{100} + 9\times 1 = \dotfill$ \end{enumerate} \end{multicols} \ No newline at end of file diff --git a/data/ex/tests/EcrireNombreLettre.0.answer b/data/ex/tests/EcrireNombreLettre.0.answer index b50b9025..d6c0de7f 100644 --- a/data/ex/tests/EcrireNombreLettre.0.answer +++ b/data/ex/tests/EcrireNombreLettre.0.answer @@ -2,40 +2,40 @@ \begin{enumerate} \item Écrire en chiffres les nombres suivants. \begin{enumerate} -\item sept-cent-cinquante-sept unités et quatre-vingt-quatre millièmes : -757,084 -\item trois-cent-quatre-millions-vingt-cinq-mille-quatre-cent-vingt : -304\,025\,420 -\item quatre-cent-quatre millièmes : -0,404 -\item cinquante-et-une unités et un dixième : -51,1 -\item deux-cent-cinquante-quatre unités et deux dixièmes : -254,2 -\item cinq-cent-quatre-vingt-trois-millions-quatre-cent-quatre : -583\,000\,404 -\item sept-cent-quatre-vingt-quatre-millions-sept-cent-cinquante-sept-mille-quatre-vingt-quatre : -784\,757\,084 -\item quatre-cent-soixante-dix-sept-millions-cinq-cent-onze-mille : -477\,511\,000 +\item quatre-cent-quinze-millions-deux-cent-soixante-cinq : +415\,000\,265 +\item cinq-cent-trente-neuf unités et onze centièmes : +539,11 +\item cinq-cent-vingt-quatre-millions-cinquante-trois-mille-neuf-cent-onze : +524\,053\,911 +\item sept-mille-sept-cent-soixante unités et quarante-neuf centièmes : +7\,760,49 +\item quatre-cent-quatre-vingt-dix-huit-millions-quarante-et-un-mille : +498\,041\,000 +\item neuf-cent-quatre-vingt-neuf-millions-sept-cent-soixante-seize-mille-quarante-neuf : +989\,776\,049 +\item deux-cent-soixante-cinq millièmes : +0,265 +\item quarante-et-un centièmes : +0,41 \end{enumerate} \item Écrire en lettres les nombres suivants (sans utiliser le mot ``virgule"). \begin{enumerate} -\item 10,472 : -dix unités et quatre-cent-soixante-douze millièmes -\item 477\,434\,000 : -quatre-cent-soixante-dix-sept-millions-quatre-cent-trente-quatre-mille -\item 4,34 : -quatre unités et trente-quatre centièmes -\item 68\,308,9 : -soixante-huit-mille-trois-cent-huit unités et neuf dixièmes -\item 913\,683\,089 : -neuf-cent-treize-millions-six-cent-quatre-vingt-trois-mille-quatre-vingt-neuf -\item 865\,000\,610 : -huit-cent-soixante-cinq-millions-six-cent-dix -\item 61 : -soixante-et-un -\item 966\,010\,472 : -neuf-cent-soixante-six-millions-dix-mille-quatre-cent-soixante-douze +\item 574\,000\,870 : +cinq-cent-soixante-quatorze-millions-huit-cent-soixante-dix +\item 97,47 : +quatre-vingt-dix-sept unités et quarante-sept centièmes +\item 10\,103,9 : +dix-mille-cent-trois unités et neuf dixièmes +\item 9,2 : +neuf unités et deux dixièmes +\item 484\,920\,000 : +quatre-cent-quatre-vingt-quatre-millions-neuf-cent-vingt-mille +\item 701\,101\,039 : +sept-cent-un-millions-cent-un-mille-trente-neuf +\item 339\,009\,747 : +trois-cent-trente-neuf-millions-neuf-mille-sept-cent-quarante-sept +\item 8,7 : +huit unités et sept dixièmes \end{enumerate} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/EcrireNombreLettre.0.statement b/data/ex/tests/EcrireNombreLettre.0.statement index 1b709bed..58559b55 100644 --- a/data/ex/tests/EcrireNombreLettre.0.statement +++ b/data/ex/tests/EcrireNombreLettre.0.statement @@ -2,24 +2,24 @@ \begin{enumerate} \item Écrire en chiffres les nombres suivants. \begin{enumerate} -\item sept-cent-cinquante-sept unités et quatre-vingt-quatre millièmes : \dotfill -\item trois-cent-quatre-millions-vingt-cinq-mille-quatre-cent-vingt : \dotfill -\item quatre-cent-quatre millièmes : \dotfill -\item cinquante-et-une unités et un dixième : \dotfill -\item deux-cent-cinquante-quatre unités et deux dixièmes : \dotfill -\item cinq-cent-quatre-vingt-trois-millions-quatre-cent-quatre : \dotfill -\item sept-cent-quatre-vingt-quatre-millions-sept-cent-cinquante-sept-mille-quatre-vingt-quatre : \dotfill -\item quatre-cent-soixante-dix-sept-millions-cinq-cent-onze-mille : \dotfill +\item quatre-cent-quinze-millions-deux-cent-soixante-cinq : \dotfill +\item cinq-cent-trente-neuf unités et onze centièmes : \dotfill +\item cinq-cent-vingt-quatre-millions-cinquante-trois-mille-neuf-cent-onze : \dotfill +\item sept-mille-sept-cent-soixante unités et quarante-neuf centièmes : \dotfill +\item quatre-cent-quatre-vingt-dix-huit-millions-quarante-et-un-mille : \dotfill +\item neuf-cent-quatre-vingt-neuf-millions-sept-cent-soixante-seize-mille-quarante-neuf : \dotfill +\item deux-cent-soixante-cinq millièmes : \dotfill +\item quarante-et-un centièmes : \dotfill \end{enumerate} \item Écrire en lettres les nombres suivants (sans utiliser le mot ``virgule"). \begin{enumerate} -\item 10,472 : \dotfill -\item 477\,434\,000 : \dotfill -\item 4,34 : \dotfill -\item 68\,308,9 : \dotfill -\item 913\,683\,089 : \dotfill -\item 865\,000\,610 : \dotfill -\item 61 : \dotfill -\item 966\,010\,472 : \dotfill +\item 574\,000\,870 : \dotfill +\item 97,47 : \dotfill +\item 10\,103,9 : \dotfill +\item 9,2 : \dotfill +\item 484\,920\,000 : \dotfill +\item 701\,101\,039 : \dotfill +\item 339\,009\,747 : \dotfill +\item 8,7 : \dotfill \end{enumerate} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/EcritureFractionnaire.0.answer b/data/ex/tests/EcritureFractionnaire.0.answer index b5cee1f7..881e2663 100644 --- a/data/ex/tests/EcritureFractionnaire.0.answer +++ b/data/ex/tests/EcritureFractionnaire.0.answer @@ -2,11 +2,11 @@ Compléter : \begin{multicols}{3}\noindent \begin{enumerate} -\item $\cfrac{8\,445}{\mathbf{1\,000}}=8{,}445$ -\item $\cfrac{5\,118}{100}=\mathbf{51{,}18}$ -\item $\cfrac{47\,710}{1\,000}=\mathbf{47{,}71}$ -\item $\cfrac{2\,826}{\mathbf{1\,000}}=2{,}826$ -\item $\cfrac{90\,980}{10\,000}=\mathbf{9{,}098}$ -\item $\cfrac{31\,090}{10\,000}=\mathbf{3{,}109}$ +\item $\cfrac{\mathbf{63\,220}}{1\,000}=63{,}22$ +\item $\cfrac{83\,870}{\mathbf{1\,000}}=83{,}87$ +\item $\cfrac{7\,819}{100}=\mathbf{78{,}19}$ +\item $\cfrac{8\,279}{\mathbf{10}}=827{,}9$ +\item $\cfrac{1\,564}{\mathbf{1\,000}}=1{,}564$ +\item $\cfrac{5\,092}{10}=\mathbf{509{,}2}$ \end{enumerate} \end{multicols} \ No newline at end of file diff --git a/data/ex/tests/EcritureFractionnaire.0.statement b/data/ex/tests/EcritureFractionnaire.0.statement index fbc1b1f4..687a0a3e 100644 --- a/data/ex/tests/EcritureFractionnaire.0.statement +++ b/data/ex/tests/EcritureFractionnaire.0.statement @@ -2,11 +2,11 @@ Compléter : \begin{multicols}{3}\noindent \begin{enumerate} -\item $\cfrac{8\,445}{\ldots}=8{,}445$ -\item $\cfrac{5\,118}{100}=\ldots$ -\item $\cfrac{47\,710}{1\,000}=\ldots$ -\item $\cfrac{2\,826}{\ldots}=2{,}826$ -\item $\cfrac{90\,980}{10\,000}=\ldots$ -\item $\cfrac{31\,090}{10\,000}=\ldots$ +\item $\cfrac{\ldots}{1\,000}=63{,}22$ +\item $\cfrac{83\,870}{\ldots}=83{,}87$ +\item $\cfrac{7\,819}{100}=\ldots$ +\item $\cfrac{8\,279}{\ldots}=827{,}9$ +\item $\cfrac{1\,564}{\ldots}=1{,}564$ +\item $\cfrac{5\,092}{10}=\ldots$ \end{enumerate} \end{multicols} \ No newline at end of file diff --git a/data/ex/tests/EtatStableSysteme2.0.answer b/data/ex/tests/EtatStableSysteme2.0.answer index 5504a302..53f19f76 100644 --- a/data/ex/tests/EtatStableSysteme2.0.answer +++ b/data/ex/tests/EtatStableSysteme2.0.answer @@ -4,31 +4,31 @@ Puisque $P$ est l'état stable, alors $P=P\times M$. \begin{align*} P\times M &= \begin{pmatrix}x&y\end{pmatrix}\times \begin{pmatrix} - \numprint{0.95} & \numprint{0.05} \\ - \numprint{0.45} & \numprint{0.55} \\ + \numprint{0.8} & \numprint{0.2} \\ + \numprint{0.3} & \numprint{0.7} \\ \end{pmatrix}\\ &= \begin{pmatrix} - \numprint{0.95}\,x + \numprint{0.45}\,y & \numprint{0.05}\,x + \numprint{0.55}\,y + \numprint{0.8}\,x + \numprint{0.3}\,y & \numprint{0.2}\,x + \numprint{0.7}\,y \end{pmatrix} \end{align*} -Or $\begin{pmatrix}x&y\end{pmatrix}=P=P\times M$, donc les coefficients des matrices sont deux à deux égaux, donc $x=\numprint{0.95}\,x + \numprint{0.45}\,y$. +Or $\begin{pmatrix}x&y\end{pmatrix}=P=P\times M$, donc les coefficients des matrices sont deux à deux égaux, donc $x=\numprint{0.8}\,x + \numprint{0.3}\,y$. D'autre part, puisque $P$ est un état probabiliste, alors $x+y=1$, donc $y=1-x$. Donc, en remplaçant $y$ par $1-x$ dans l'équation précédente, on obtient : \begin{align*} - x &= \numprint{0.95}\,x + \numprint{0.45}\,(1-x) \\ - x &= \numprint{0.95}\,x + \numprint{0.45} - \numprint{0.45}\,x\\ - x-\numprint{0.95}\,x +\numprint{0.45}\,x &= \numprint{0.45}\\ - (1-\numprint{0.95}+\numprint{0.45}) \,x &= \numprint{0.45}\\ - \numprint{0.5}\,x &= \numprint{0.45}\\ - x &= \frac{\numprint{0.45}}{\numprint{0.5}}\\ -x &= \numprint{0.9} + x &= \numprint{0.8}\,x + \numprint{0.3}\,(1-x) \\ + x &= \numprint{0.8}\,x + \numprint{0.3} - \numprint{0.3}\,x\\ + x-\numprint{0.8}\,x +\numprint{0.3}\,x &= \numprint{0.3}\\ + (1-\numprint{0.8}+\numprint{0.3}) \,x &= \numprint{0.3}\\ + \numprint{0.5}\,x &= \numprint{0.3}\\ + x &= \frac{\numprint{0.3}}{\numprint{0.5}}\\ +x &= \numprint{0.6} \end{align*} -Enfin, puisque $y=1-x$, alors $y=1-\numprint{0.9}=\numprint{0.1}$. +Enfin, puisque $y=1-x$, alors $y=1-\numprint{0.6}=\numprint{0.4}$. L'unique état stable de ce graphe est donc $\begin{pmatrix} -\numprint{0.9} & -\numprint{0.1} +\numprint{0.6} & +\numprint{0.4} \end{pmatrix}$. \ No newline at end of file diff --git a/data/ex/tests/EtatStableSysteme2.0.statement b/data/ex/tests/EtatStableSysteme2.0.statement index b77a24c2..fbd1be32 100644 --- a/data/ex/tests/EtatStableSysteme2.0.statement +++ b/data/ex/tests/EtatStableSysteme2.0.statement @@ -3,8 +3,8 @@ On considère un graphe probabiliste d'ordre 2, dont la matrice de transition es \[ M=\begin{pmatrix} - \numprint{0.95} & \numprint{0.05} \\ - \numprint{0.45} & \numprint{0.55} \\ + \numprint{0.8} & \numprint{0.2} \\ + \numprint{0.3} & \numprint{0.7} \\ \end{pmatrix} \] diff --git a/data/ex/tests/Fd1Tangentes.0.answer b/data/ex/tests/Fd1Tangentes.0.answer index 9b71c4d3..28988710 100644 --- a/data/ex/tests/Fd1Tangentes.0.answer +++ b/data/ex/tests/Fd1Tangentes.0.answer @@ -1,23 +1,23 @@ \exercice* \begin{enumerate} \item On lit graphiquement le coefficient directeur de chacune des tangentes en ces points.\par -$f'\,(-4)=4 \qquad f'\,(0)=\dfrac{-3}{2} \qquad f'\,(4)=0$. +$f'\,(-3)=\dfrac{1}{3} \qquad f'\,(1)=0 \qquad f'\,(3)=-4$. \item \begin{asy}[height=6.5cm] import graph; import interpolate; import geometry; defaultpen(fontsize(9pt)); -real[] xpt={-6.1,-5,-1,01,05,6.1}; -real[] ypt={02,-2,00,03,-2,-3}; -real[] dy= {00,03,-2,0.75,00,00}; +real[] xpt={-6.1,-3,-2,02,05,6.1}; +real[] ypt={01,-1,00,03,03,03}; +real[] dy= {00,00,-0.6666666666666666,01,01,00}; real f(real t){return pwhermite(xpt,ypt,dy)(t);} path Cf=graph(f,-6.1,6.1); void tangente(int k,real lg=sqrt(1+dy[k]^2),real ld=lg, pen p=black+1, arrowbar arr=Arrows(SimpleHead,size=9pt)) { draw(((xpt[k],ypt[k])-lg*unit((1,dy[k])))--((xpt[k],ypt[k])+ld*unit((1,dy[k]))),p,arr); dot((xpt[k],ypt[k])); } -xlimits(-6.1, 6.1); +xlimits(-4.1, 6.1); ylimits(-5.5, 5.5, Crop); xaxis(axis=BottomTop, p=invisible, ticks=Ticks(format="%", Step=1, extend=true, @@ -36,11 +36,11 @@ end=false, endlabel=false, beginlabel=false, NoZero)); labelx(L=scale(.7)*"$0$", (0,0), align=SW); label("$\mathcal C_f$", (-6, f(-6)), 1.5NE, brown); draw(Cf, brown+1); -tangente(1,lg=sqrt(10)); -tangente(2,lg=sqrt(5)); -tangente(3,lg=sqrt(25)); -tangente(4,lg=sqrt(1)); -xlimits(-6.1, 6.1, Crop); +tangente(1,lg=sqrt(1)); +tangente(2,lg=sqrt(13)); +tangente(3,lg=sqrt(2)); +tangente(4,lg=sqrt(2)); +xlimits(-4.1, 6.1, Crop); ylimits(-5.5, 5.5, Crop); \end{asy} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/Fd1Tangentes.0.statement b/data/ex/tests/Fd1Tangentes.0.statement index aa0e8533..7f51f4ce 100644 --- a/data/ex/tests/Fd1Tangentes.0.statement +++ b/data/ex/tests/Fd1Tangentes.0.statement @@ -1,14 +1,14 @@ \exercice \begin{minipage}[]{\linewidth-8cm} \begin{enumerate} -\item Déterminer graphiquement les nombres dérivés de la fonction $f$ en $\qquad x=-4 \qquad x=0 \qquad x=4$. +\item Déterminer graphiquement les nombres dérivés de la fonction $f$ en $\qquad x=-3 \qquad x=1 \qquad x=3$. \item On considère le tableau de valeurs suivant :\par \renewcommand{\arraystretch}{2} \begin{tabularx}{\linewidth}[t]{|*5{>{\centering\arraybackslash}X|}} \hline -$x$ & $-5$ & $-1$ & $1$ & $5$ \\ \hline -$g\,(x)$ & $-2$ & $0$ & $3$ & $-2$ \\ \hline -$g'\,(x)$ & $3$ & $-2$ & $\dfrac{3}{4}$ & $0$ \\ \hline +$x$ & $-3$ & $-2$ & $2$ & $5$ \\ \hline +$g\,(x)$ & $-1$ & $0$ & $3$ & $3$ \\ \hline +$g'\,(x)$ & $0$ & $\dfrac{-2}{3}$ & $1$ & $1$ \\ \hline \end{tabularx} \begin{enumerate} \item Dans un nouveau repère, placer les points de la courbe $\mathcal{C}_g$ ainsi connus. @@ -24,9 +24,9 @@ import graph; import interpolate; import geometry; defaultpen(fontsize(9pt)); -real[] xpt={-6.1,-4,00,04,6.1}; -real[] ypt={00,-2,02,01,-2}; -real[] dy= {00,04,-1.5,00,00}; +real[] xpt={-6.1,-3,01,03,6.1}; +real[] ypt={-1,04,-2,00,-2}; +real[] dy= {00,0.3333333333333333,00,-4,00}; real f(real t){return pwhermite(xpt,ypt,dy)(t);} path Cf=graph(f,-6.1,6.1); void tangente(int k,real lg=sqrt(1+dy[k]^2),real ld=lg, pen p=black+1, arrowbar arr=Arrows(SimpleHead,size=9pt)) { @@ -50,11 +50,11 @@ yequals(L="$x$", 0, extend=false, arrow=Arrow(HookHead, size=9pt), p=black+1, ticks=Ticks(scale(.7)*Label(filltype=Fill(white)), Step=1, Size=3pt, end=false, endlabel=false, beginlabel=false, NoZero)); labelx(L=scale(.7)*"$0$", (0,0), align=SW); -label("$\mathcal C_f$", (-6, f(-6)), 1.5NE, brown); +label("$\mathcal C_f$", (-6, f(-6)), 1.5SE, brown); draw(Cf, brown+1.5); -tangente(1,lg=sqrt(17)); -tangente(2,lg=sqrt(13)); -tangente(3,lg=sqrt(1)); +tangente(1,lg=sqrt(10)); +tangente(2,lg=sqrt(1)); +tangente(3,lg=sqrt(17)); xlimits(-6.1, 6.1, Crop); ylimits(-5.5, 5.5, Crop); \end{asy} diff --git a/data/ex/tests/InterpolationMatrices.0.answer b/data/ex/tests/InterpolationMatrices.0.answer index acb550c8..513dd326 100644 --- a/data/ex/tests/InterpolationMatrices.0.answer +++ b/data/ex/tests/InterpolationMatrices.0.answer @@ -5,59 +5,59 @@ \begin{enumerate} \item \begin{itemize} - \item Puisque $A\,( \numprint{4}~;~\numprint{-75} )$ est sur la courbe de $f$, alors $f\,( \numprint{4} )=\numprint{-75}$, soit - $a \times \numprint{4}^2+b\times \numprint{4}+c=\numprint{-75}$, - c'est-à-dire $\numprint{16}\,a + \numprint{4}\,b + c = \numprint{-75}$. - \item De même, puisque $B\,( \numprint{5}~;~\numprint{-126} )$ est sur la courbe de $f$, alors $f\,( \numprint{5} )=\numprint{-126}$, soit - $a \times \numprint{5}^2+b\times \numprint{5}+c=\numprint{-126}$, - c'est-à-dire $\numprint{25}\,a + \numprint{5}\,b + c = \numprint{-126}$. - \item Enfin, puisque $C\,( \numprint{6}~;~\numprint{-191} )$ est sur la courbe de $f$, alors $f\,( \numprint{6} )=\numprint{-191}$, soit - $a \times \numprint{6}^2+b\times \numprint{6}+c=\numprint{-191}$, - c'est-à-dire $\numprint{36}\,a + \numprint{6}\,b + c = \numprint{-191}$. + \item Puisque $A\,( \numprint{6}~;~\numprint{-649} )$ est sur la courbe de $f$, alors $f\,( \numprint{6} )=\numprint{-649}$, soit + $a \times \numprint{6}^2+b\times \numprint{6}+c=\numprint{-649}$, + c'est-à-dire $\numprint{36}\,a + \numprint{6}\,b + c = \numprint{-649}$. + \item De même, puisque $B\,( \numprint{8}~;~\numprint{-1141} )$ est sur la courbe de $f$, alors $f\,( \numprint{8} )=\numprint{-1141}$, soit + $a \times \numprint{8}^2+b\times \numprint{8}+c=\numprint{-1141}$, + c'est-à-dire $\numprint{64}\,a + \numprint{8}\,b + c = \numprint{-1141}$. + \item Enfin, puisque $C\,( \numprint{9}~;~\numprint{-1438} )$ est sur la courbe de $f$, alors $f\,( \numprint{9} )=\numprint{-1438}$, soit + $a \times \numprint{9}^2+b\times \numprint{9}+c=\numprint{-1438}$, + c'est-à-dire $\numprint{81}\,a + \numprint{9}\,b + c = \numprint{-1438}$. \end{itemize} On en déduit le système suivant : \[ \left\{\begin{array}{rcl} - \numprint{16}\,a + \numprint{4}\,b + c &=& \numprint{-75} \\ - \numprint{25}\,a + \numprint{5}\,b + c &=& \numprint{-126} \\ - \numprint{36}\,a + \numprint{6}\,b + c &=& \numprint{-191} \\ + \numprint{36}\,a + \numprint{6}\,b + c &=& \numprint{-649} \\ + \numprint{64}\,a + \numprint{8}\,b + c &=& \numprint{-1141} \\ + \numprint{81}\,a + \numprint{9}\,b + c &=& \numprint{-1438} \\ \end{array}\right.\] \item \begin{align*} \left\{\begin{array}{rcl} - \numprint{16}\,a + \numprint{4}\,b + c &=& \numprint{-75} \\ - \numprint{25}\,a + \numprint{5}\,b + c &=& \numprint{-126} \\ - \numprint{36}\,a + \numprint{6}\,b + c &=& \numprint{-191} \\ + \numprint{36}\,a + \numprint{6}\,b + c &=& \numprint{-649} \\ + \numprint{64}\,a + \numprint{8}\,b + c &=& \numprint{-1141} \\ + \numprint{81}\,a + \numprint{9}\,b + c &=& \numprint{-1438} \\ \end{array}\right. &\iff \begin{pmatrix} -\numprint{16}\,a + \numprint{4}\,b + c \\ -\numprint{25}\,a + \numprint{5}\,b + c \\ \numprint{36}\,a + \numprint{6}\,b + c \\ -\end{pmatrix} = \begin{pmatrix}\numprint{-75}\\\numprint{-126}\\\numprint{-191}\\\end{pmatrix}\\ +\numprint{64}\,a + \numprint{8}\,b + c \\ +\numprint{81}\,a + \numprint{9}\,b + c \\ +\end{pmatrix} = \begin{pmatrix}\numprint{-649}\\\numprint{-1141}\\\numprint{-1438}\\\end{pmatrix}\\ &\iff -\begin{pmatrix}\numprint{16} & \numprint{4} & \numprint{1}\\\numprint{25} & \numprint{5} & \numprint{1}\\\numprint{36} & \numprint{6} & \numprint{1}\\\end{pmatrix} \times \begin{pmatrix}a\\b\\c\\\end{pmatrix} = \begin{pmatrix}\numprint{-75}\\\numprint{-126}\\\numprint{-191}\\\end{pmatrix} \\ +\begin{pmatrix}\numprint{36} & \numprint{6} & \numprint{1}\\\numprint{64} & \numprint{8} & \numprint{1}\\\numprint{81} & \numprint{9} & \numprint{1}\\\end{pmatrix} \times \begin{pmatrix}a\\b\\c\\\end{pmatrix} = \begin{pmatrix}\numprint{-649}\\\numprint{-1141}\\\numprint{-1438}\\\end{pmatrix} \\ &\iff M\, X=R \end{align*} - Avec : $M= \begin{pmatrix}\numprint{16} & \numprint{4} & \numprint{1}\\\numprint{25} & \numprint{5} & \numprint{1}\\\numprint{36} & \numprint{6} & \numprint{1}\\\end{pmatrix}$, $X= \begin{pmatrix}a\\b\\c\\\end{pmatrix}$ et $R= \begin{pmatrix}\numprint{-75}\\\numprint{-126}\\\numprint{-191}\\\end{pmatrix}$. + Avec : $M= \begin{pmatrix}\numprint{36} & \numprint{6} & \numprint{1}\\\numprint{64} & \numprint{8} & \numprint{1}\\\numprint{81} & \numprint{9} & \numprint{1}\\\end{pmatrix}$, $X= \begin{pmatrix}a\\b\\c\\\end{pmatrix}$ et $R= \begin{pmatrix}\numprint{-649}\\\numprint{-1141}\\\numprint{-1438}\\\end{pmatrix}$. \end{enumerate} \item Comme $M$ est inversible, et que $M\,X = R$, alors $X = M^{-1}\times R$. À la calculatrice, on obtient - $M^{-1}\times R=\begin{pmatrix}\numprint{16} & \numprint{4} & \numprint{1}\\\numprint{25} & \numprint{5} & \numprint{1}\\\numprint{36} & \numprint{6} & \numprint{1}\\\end{pmatrix}^{-1}\times \begin{pmatrix}\numprint{-75}\\\numprint{-126}\\\numprint{-191}\\\end{pmatrix} = \begin{pmatrix}\numprint{-7}\\\numprint{12}\\\numprint{-11}\\\end{pmatrix}$. + $M^{-1}\times R=\begin{pmatrix}\numprint{36} & \numprint{6} & \numprint{1}\\\numprint{64} & \numprint{8} & \numprint{1}\\\numprint{81} & \numprint{9} & \numprint{1}\\\end{pmatrix}^{-1}\times \begin{pmatrix}\numprint{-649}\\\numprint{-1141}\\\numprint{-1438}\\\end{pmatrix} = \begin{pmatrix}\numprint{-17}\\\numprint{-8}\\\numprint{11}\\\end{pmatrix}$. - Ainsi, $a=\numprint{-7}$, $b=\numprint{12}$, et $c=\numprint{-11}$. + Ainsi, $a=\numprint{-17}$, $b=\numprint{-8}$, et $c=\numprint{11}$. \item -En utilisant les valeurs de $a$, $b$, et $c$ calculées précédemment, nous connaissons l'expression de la fonction : $f\,(x) = \numprint{-7}\,x^2 +\numprint{12}\,x -\numprint{11}$. +En utilisant les valeurs de $a$, $b$, et $c$ calculées précédemment, nous connaissons l'expression de la fonction : $f\,(x) = \numprint{-17}\,x^2 -\numprint{8}\,x +\numprint{11}$. -Nous pouvons maintenant calculer l'image de $\numprint{17}$ par cette fonction : +Nous pouvons maintenant calculer l'image de $\numprint{11}$ par cette fonction : \begin{align*} -f\,( \numprint{17} ) -&= \numprint{-7} \times \numprint{17}^2 +\numprint{12} \times \numprint{17} -\numprint{11}\\ -&= \numprint{-1830} +f\,( \numprint{11} ) +&= \numprint{-17} \times \numprint{11}^2 -\numprint{8} \times \numprint{11} +\numprint{11}\\ +&= \numprint{-2134} \end{align*} -Donc $f\,( \numprint{17} ) = \numprint{-1830}$. +Donc $f\,( \numprint{11} ) = \numprint{-2134}$. \end{enumerate} diff --git a/data/ex/tests/InterpolationMatrices.0.statement b/data/ex/tests/InterpolationMatrices.0.statement index e2761d29..83cf6624 100644 --- a/data/ex/tests/InterpolationMatrices.0.statement +++ b/data/ex/tests/InterpolationMatrices.0.statement @@ -1,8 +1,8 @@ \exercice Dans un repère orthonormé, on cherche à déterminer l'équation d'une fonction dont la courbe passe par les points -$A\,( \numprint{4} ~;~ \numprint{-75} )$, -$B\,( \numprint{5} ~;~ \numprint{-126} )$ et -$C\,( \numprint{6} ~;~ \numprint{-191} )$. +$A\,( \numprint{6} ~;~ \numprint{-649} )$, +$B\,( \numprint{8} ~;~ \numprint{-1141} )$ et +$C\,( \numprint{9} ~;~ \numprint{-1438} )$. On cherche un trinôme du second degré, c'est-à-dire une fonction $f$ définie sur $\interval[open]{-\infty}{+\infty}$ par \mbox{$f\,(x) = a\,x^2 + b\,x + c$} où $a$, $b$ et $c$ sont trois nombres réels, que l'on cherche à déterminer. @@ -13,13 +13,13 @@ On cherche un trinôme du second degré, c'est-à-dire une fonction $f$ définie \item À partir des données de l'énoncé, écrire un système d'équations traduisant cette situation. \item En déduire que le système précédent est équivalent à : $M\,X = R$ avec - $M = \begin{pmatrix}\numprint{16} & \numprint{4} & \numprint{1}\\\numprint{25} & \numprint{5} & \numprint{1}\\\numprint{36} & \numprint{6} & \numprint{1}\\\end{pmatrix}$, $X= \begin{pmatrix}a\\b\\c\\\end{pmatrix}$ et $R$ une matrice colonne que l'on précisera. + $M = \begin{pmatrix}\numprint{36} & \numprint{6} & \numprint{1}\\\numprint{64} & \numprint{8} & \numprint{1}\\\numprint{81} & \numprint{9} & \numprint{1}\\\end{pmatrix}$, $X= \begin{pmatrix}a\\b\\c\\\end{pmatrix}$ et $R$ une matrice colonne que l'on précisera. \end{enumerate} \end{enumerate} \begin{enumerate} \setcounter{enumi}{1} \item On admet que la matrice $M$ est inversible. Déterminer les valeurs des cœfficients $a$, $b$ et $c$, en détaillant les calculs. - \item Quelle est la valeur de $f\,( \numprint{17} )$ ? + \item Quelle est la valeur de $f\,( \numprint{11} )$ ? \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/PlaceVirgule.0.answer b/data/ex/tests/PlaceVirgule.0.answer index e909b292..fa8afe16 100644 --- a/data/ex/tests/PlaceVirgule.0.answer +++ b/data/ex/tests/PlaceVirgule.0.answer @@ -1,16 +1,16 @@ \exercice* -Placer une virgule (en ajoutant éventuellement des zéros) dans le nombre 452378 de telle sorte que : +Placer une virgule (en ajoutant éventuellement des zéros) dans le nombre 694187 de telle sorte que : \begin{enumerate} -\item le chiffre 7 soit le chiffre des dizaines : -452\,378 -\item le chiffre 2 soit le chiffre des dixièmes : -45,237\,8 -\item le chiffre 8 soit le chiffre des unités : -452\,378 -\item le chiffre 5 soit le chiffre des millièmes : -0,045\,237\,8 -\item le chiffre 3 soit le chiffre des milliers : -4\,523\,780 -\item le chiffre 8 soit le chiffre des centièmes : -4\,523,78 +\item le chiffre 1 soit le chiffre des millièmes : +6,941\,87 +\item le chiffre 4 soit le chiffre des unités : +694,187 +\item le chiffre 4 soit le chiffre des centièmes : +6,941\,87 +\item le chiffre 9 soit le chiffre des centaines : +6\,941,87 +\item le chiffre 4 soit le chiffre des milliers : +694\,187 +\item le chiffre 6 soit le chiffre des dixièmes : +0,694\,187 \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/PlaceVirgule.0.statement b/data/ex/tests/PlaceVirgule.0.statement index 0dff6426..c9136822 100644 --- a/data/ex/tests/PlaceVirgule.0.statement +++ b/data/ex/tests/PlaceVirgule.0.statement @@ -1,16 +1,16 @@ \exercice -Placer une virgule (en ajoutant éventuellement des zéros) dans le nombre 452378 de telle sorte que : +Placer une virgule (en ajoutant éventuellement des zéros) dans le nombre 694187 de telle sorte que : \begin{enumerate} -\item le chiffre 7 soit le chiffre des dizaines : +\item le chiffre 1 soit le chiffre des millièmes : \dotfill -\item le chiffre 2 soit le chiffre des dixièmes : +\item le chiffre 4 soit le chiffre des unités : \dotfill -\item le chiffre 8 soit le chiffre des unités : +\item le chiffre 4 soit le chiffre des centièmes : \dotfill -\item le chiffre 5 soit le chiffre des millièmes : +\item le chiffre 9 soit le chiffre des centaines : \dotfill -\item le chiffre 3 soit le chiffre des milliers : +\item le chiffre 4 soit le chiffre des milliers : \dotfill -\item le chiffre 8 soit le chiffre des centièmes : +\item le chiffre 6 soit le chiffre des dixièmes : \dotfill \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/Sd1FormeCanonique.0.answer b/data/ex/tests/Sd1FormeCanonique.0.answer index 611b34cf..b0c72c64 100644 --- a/data/ex/tests/Sd1FormeCanonique.0.answer +++ b/data/ex/tests/Sd1FormeCanonique.0.answer @@ -1,12 +1,12 @@ \exercice* Donner la forme canonique des polynômes $P$ , $Q$ , $R$ et $S$ . \begin{align*} -P\,(x) &= x^{2}-16\,x+4 & Q\,(x) &= x^{2}+7\,x+8 & S\,(x) &= 4\,x^{2}-7\,x-3\\ - &= \left( x-8\right) ^{2}-8^{2}+4 & &= \left( x+\dfrac{7}{2}\right) ^{2}-\left( \dfrac{7}{2} \right) ^{2}+8 & &= 4\times \left( x^{2}-\dfrac{7}{4}\,x-\dfrac{3}{4}\right) \\ - &= \left( x-8\right) ^{2}-64+4 & &= \left( x+\dfrac{7}{2}\right) ^{2}+\dfrac{-49}{4}+\dfrac{8_{\times 4}}{1_{\times 4}} & &= 4\times \left( \left( x-\dfrac{7}{8}\right) ^{2}-\left( \dfrac{7}{8} \right) ^{2}+\dfrac{-3}{4}\right) \\ -\Aboxed{P\,(x) &= \left( x-8\right) ^{2}-60} & &= \left( x+\dfrac{7}{2}\right) ^{2}+\dfrac{-49}{4}+\dfrac{32}{4} & &= 4\times \left( \left( x-\dfrac{7}{8}\right) ^{2}+\dfrac{-49}{64}+\dfrac{-3_{\times 16}}{4_{\times 16}}\right) \\ -R\,(x) &= 25\,x^{2}-60\,x+36 & \Aboxed{Q\,(x) &= \left( x+\dfrac{7}{2}\right) ^{2}+\dfrac{-17}{4}} & &= 4\times \left( \left( x-\dfrac{7}{8}\right) ^{2}+\dfrac{-49}{64}+\dfrac{-48}{64}\right) \\ - &= \left( 5\,x-6\right) ^{2} & & & &= 4\times \left( \left( x-\dfrac{7}{8}\right) ^{2}+\dfrac{-97}{64}\right) \\ - &= \left( 5\times \left( x-\dfrac{6}{5}\right) \right) ^{2} & & & &= 4\times \left( x-\dfrac{7}{8}\right) ^{2}+\dfrac{-97\times \cancel{4}}{\cancel{4}\times 16}\\ -\Aboxed{R\,(x) &= 25\times \left( x-\dfrac{6}{5}\right) ^{2}} & & & \Aboxed{S\,(x) &= 4\times \left( x-\dfrac{7}{8}\right) ^{2}+\dfrac{-97}{16}}\\ +P\,(x) &= x^{2}-11\,x-7 & Q\,(x) &= -3\,x^{2}+3\,x+5 & R\,(x) &= x^{2}-14\,x-1\\ + &= \left( x-\dfrac{11}{2}\right) ^{2}-\left( \dfrac{11}{2} \right) ^{2}-7 & &= -3\times \left( x^{2}-x-\dfrac{5}{3}\right) & &= \left( x-7\right) ^{2}-7^{2}-1\\ + &= \left( x-\dfrac{11}{2}\right) ^{2}+\dfrac{-121}{4}-\dfrac{7_{\times 4}}{1_{\times 4}} & &= -3\times \left( \left( x-\dfrac{1}{2}\right) ^{2}-\left( \dfrac{1}{2} \right) ^{2}+\dfrac{-5}{3}\right) & &= \left( x-7\right) ^{2}-49-1\\ + &= \left( x-\dfrac{11}{2}\right) ^{2}+\dfrac{-121}{4}-\dfrac{28}{4} & &= -3\times \left( \left( x-\dfrac{1}{2}\right) ^{2}+\dfrac{-1_{\times 3}}{4_{\times 3}}+\dfrac{-5_{\times 4}}{3_{\times 4}}\right) & \Aboxed{R\,(x) &= \left( x-7\right) ^{2}-50}\\ +\Aboxed{P\,(x) &= \left( x-\dfrac{11}{2}\right) ^{2}+\dfrac{-149}{4}} & &= -3\times \left( \left( x-\dfrac{1}{2}\right) ^{2}+\dfrac{-3}{12}+\dfrac{-20}{12}\right) & S\,(x) &= 64\,x^{2}+96\,x+36\\ +& & &= -3\times \left( \left( x-\dfrac{1}{2}\right) ^{2}+\dfrac{-23}{12}\right) & &= \left( 8\,x+6\right) ^{2}\\ +& & &= -3\times \left( x-\dfrac{1}{2}\right) ^{2}+\dfrac{-23\times \cancel{3}\times \left ( -1\right ) }{\cancel{3}\times 4} & &= \left( 8\times \left( x+\dfrac{6}{8}\right) \right) ^{2}\\ +& & \Aboxed{Q\,(x) &= -3\times \left( x-\dfrac{1}{2}\right) ^{2}+\dfrac{23}{4}} & \Aboxed{S\,(x) &= 64\times \left( x+\dfrac{3}{4}\right) ^{2}}\\ \end{align*} \ No newline at end of file diff --git a/data/ex/tests/Sd1FormeCanonique.0.statement b/data/ex/tests/Sd1FormeCanonique.0.statement index c38b869d..fe114221 100644 --- a/data/ex/tests/Sd1FormeCanonique.0.statement +++ b/data/ex/tests/Sd1FormeCanonique.0.statement @@ -1,5 +1,5 @@ \exercice Donner la forme canonique des polynômes $P$ , $Q$ , $R$ et $S$ . \begin{align*} -P\,(x) &= x^{2}-16\,x+4 & Q\,(x) &= x^{2}+7\,x+8 & R\,(x) &= 25\,x^{2}-60\,x+36 & S\,(x) &= 4\,x^{2}-7\,x-3 \\ +P\,(x) &= x^{2}-11\,x-7 & Q\,(x) &= -3\,x^{2}+3\,x+5 & R\,(x) &= x^{2}-14\,x-1 & S\,(x) &= 64\,x^{2}+96\,x+36 \\ \end{align*} \ No newline at end of file diff --git a/data/ex/tests/TermesDUneSuite.0.answer b/data/ex/tests/TermesDUneSuite.0.answer index 7b49b109..9be934ce 100644 --- a/data/ex/tests/TermesDUneSuite.0.answer +++ b/data/ex/tests/TermesDUneSuite.0.answer @@ -1,44 +1,44 @@ \exercice* \begin{enumerate} - \item Selon l'énoncé, le premier terme de $\left(u_n\right)$ est $u_1=-2$. Puisque chaque terme (sauf le premier) est égal à l'inverse du précédent, on a : -$u_2=\frac{1}{ u_1 } =\frac{1}{ -2 } =-\frac{1}{ 2 }$ ; $u_3=\frac{1}{ u_2 } =\frac{1}{ -\frac{ 1 }{ 2 } } =-2$ ; $u_4=\frac{1}{ u_3 } =\frac{1}{ -2 } =-\frac{1}{ 2 }$ ; $u_5=\frac{1}{ u_4 } =\frac{1}{ -\frac{ 1 }{ 2 } } =-2$ ; $u_6=\frac{1}{ u_5 } =\frac{1}{ -2 } =-\frac{1}{ 2 }$ ; $u_7=\frac{1}{ u_6 } =\frac{1}{ -\frac{ 1 }{ 2 } } =-2$. + \item Selon l'énoncé, le premier terme de $\left(u_n\right)$ est $u_1=2$. Puisque chaque terme (sauf le premier) est égal à l'opposé du précédent, on a : +$u_2=-u_1 =-2$ ; $u_3=-u_2 =2$ ; $u_4=-u_3 =-2$ ; $u_5=-u_4 =2$ ; $u_6=-u_5 =-2$. \begin{enumerate} - \item Calcul du septième terme : -le premier terme est $u_1$ ; le deuxième terme est $u_2$ ; le troisième terme est $u_3$ ; le quatrième terme est $u_4$ ; le cinquième terme est $u_5$ ; le sixième terme est $u_6$ ; le septième terme est $u_7$. -Le terme demandé est donc : $u_7=-2$. -\item Le terme de rang 6 est : $u_6=-\frac{ 1 }{ 2 }$. -\item Nous avons calculé que : $u_4=-\frac{ 1 }{ 2 }$. + \item Calcul du cinquième terme : +le premier terme est $u_1$ ; le deuxième terme est $u_2$ ; le troisième terme est $u_3$ ; le quatrième terme est $u_4$ ; le cinquième terme est $u_5$. +Le terme demandé est donc : $u_5=2$. +\item Le terme de rang 6 est : $u_6=-2$. +\item Nous avons calculé que : $u_3=2$. \end{enumerate} - \item La suite $u$ est définie pour $n\geq1$ par : $u_n=\frac{ 3 }{ 5 }n-6$. + \item La suite $\left(u_n\right)$ est définie pour $n\geq1$ par : $u_n=n-4$. Elle est donc définie par son terme général : pour calculer un terme de rang $n$, on peut calculer directement l'image de $n$ par la suite. \begin{enumerate} - \item Calcul du septième terme : -le premier terme est $u_1$ ; le deuxième terme est $u_2$ ; le troisième terme est $u_3$ ; le quatrième terme est $u_4$ ; le cinquième terme est $u_5$ ; le sixième terme est $u_6$ ; le septième terme est $u_7$. -Le terme demandé est donc : $u_7= -\frac{ 3 }{ 5 }\times 7-6 = \frac{ 21 }{ 5 } - \frac{ 6 \times 5 }{ 5 } = \frac{ 21 -30 }{ 5 } = \frac{ -9 }{ 5 }$. -La solution est $u_{ 7 }=\frac{ -9 }{ 5 }$. + \item Calcul du cinquième terme : +le premier terme est $u_1$ ; le deuxième terme est $u_2$ ; le troisième terme est $u_3$ ; le quatrième terme est $u_4$ ; le cinquième terme est $u_5$. +Le terme demandé est donc : $u_5= +5-4 = 1$. +La solution est $u_{ 5 }=1$. \item Le terme de rang 6 est $u_{ 6 }$. -Le terme demandé est donc : $u_{ 6 }=\frac{ 3 }{ 5 }\times 6-6 = \frac{ 18 }{ 5 } - \frac{ 6 \times 5 }{ 5 } = \frac{ 18 -30 }{ 5 } = \frac{ -12 }{ 5 }$. -La solution est donc : $u_{ 6 }=\frac{ -12 }{ 5 }$. +Le terme demandé est donc : $u_{ 6 }=6-4 = 2$. +La solution est donc : $u_{ 6 }=2$. \item -On a : $u_{ 4 }=\frac{ 3 }{ 5 }\times 4-6 = \frac{ 12 }{ 5 } - \frac{ 6 \times 5 }{ 5 } = \frac{ 12 -30 }{ 5 } = \frac{ -18 }{ 5 }$. -La solution est donc : $u_{ 4 }=\frac{ -18 }{ 5 }$. +On a : $u_{ 3 }=3-4 = -1$. +La solution est donc : $u_{ 3 }=-1$. \end{enumerate} -\item La suite $\left(u_n\right)$ est définie par récurrence, pour $n\geq3$, par : +\item La suite $u$ est définie par récurrence, pour $n\geq1$, par : \[\left\{\begin{array}{l} - u_3=-5\\ - \text{Pour tout $n\geq3$ : } u_{n+1}=\frac{ 4 }{ 5 }u_n. + u_1=-7\\ + \text{Pour tout $n\geq1$ : } u_{n+1}=\frac{ 1 }{ 5 }u_n. \end{array}\right.\] \begin{align*} -u_4 &= \frac{ 4 }{ 5 }u_3 =\frac{ 4 }{ 5 }\times \left( -5 \right) =\frac{ -20 }{ 5 } =-4 \\u_5 &= \frac{ 4 }{ 5 }u_4 =\frac{ 4 }{ 5 }\times \left( -4 \right) =\frac{ -16 }{ 5 } \\u_6 &= \frac{ 4 }{ 5 }u_5 =\frac{ 4 }{ 5 }\times \frac{ -16 }{ 5 } =\frac{ -64 }{ 25 } \\u_7 &= \frac{ 4 }{ 5 }u_6 =\frac{ 4 }{ 5 }\times \frac{ -64 }{ 25 } =\frac{ -256 }{ 125 } \\u_8 &= \frac{ 4 }{ 5 }u_7 =\frac{ 4 }{ 5 }\times \frac{ -256 }{ 125 } =\frac{ -1024 }{ 625 } \\u_9 &= \frac{ 4 }{ 5 }u_8 =\frac{ 4 }{ 5 }\times \frac{ -1024 }{ 625 } =\frac{ -4096 }{ 3125 } +u_2 &= \frac{ 1 }{ 5 }u_1 =\frac{ 1 }{ 5 }\times \left( -7 \right) =\frac{ -7 }{ 5 } \\u_3 &= \frac{ 1 }{ 5 }u_2 =\frac{ 1 }{ 5 }\times \frac{ -7 }{ 5 } =\frac{ -7 }{ 25 } \\u_4 &= \frac{ 1 }{ 5 }u_3 =\frac{ 1 }{ 5 }\times \frac{ -7 }{ 25 } =\frac{ -7 }{ 125 } \\u_5 &= \frac{ 1 }{ 5 }u_4 =\frac{ 1 }{ 5 }\times \frac{ -7 }{ 125 } =\frac{ -7 }{ 625 } \\u_6 &= \frac{ 1 }{ 5 }u_5 =\frac{ 1 }{ 5 }\times \frac{ -7 }{ 625 } =\frac{ -7 }{ 3125 } \end{align*} \begin{enumerate} - \item Calcul du septième terme : -le premier terme est $u_3$ ; le deuxième terme est $u_4$ ; le troisième terme est $u_5$ ; le quatrième terme est $u_6$ ; le cinquième terme est $u_7$ ; le sixième terme est $u_8$ ; le septième terme est $u_9$. -Le terme demandé est donc : $u_9=\frac{ -4096 }{ 3125 }$. -\item Le terme de rang 6 est : $u_6=\frac{ -64 }{ 25 }$. -\item Nous avons calculé que : $u_4=-4$. + \item Calcul du cinquième terme : +le premier terme est $u_1$ ; le deuxième terme est $u_2$ ; le troisième terme est $u_3$ ; le quatrième terme est $u_4$ ; le cinquième terme est $u_5$. +Le terme demandé est donc : $u_5=\frac{ -7 }{ 625 }$. +\item Le terme de rang 6 est : $u_6=\frac{ -7 }{ 3125 }$. +\item Nous avons calculé que : $u_3=\frac{ -7 }{ 25 }$. \end{enumerate} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/TermesDUneSuite.0.statement b/data/ex/tests/TermesDUneSuite.0.statement index 19983555..b2e8c5af 100644 --- a/data/ex/tests/TermesDUneSuite.0.statement +++ b/data/ex/tests/TermesDUneSuite.0.statement @@ -1,16 +1,16 @@ \exercice Pour chacune des suites $u$ suivantes, calculer : - (a) le septième terme ; + (a) le cinquième terme ; (b) le terme de rang 6 ; - (c) $u_4$. + (c) $u_3$. \begin{enumerate} - \item $\left(u_n\right)$ est une suite de premier terme $u_1=-2$, et dont chaque terme (sauf le premier) est égal à l'inverse du précédent. - \item $u$ est la suite définie pour $n\geq1$ par : $u_n=\frac{ 3 }{ 5 }n-6$. + \item $\left(u_n\right)$ est une suite de premier terme $u_1=2$, et dont chaque terme (sauf le premier) est égal à l'opposé du précédent. + \item $\left(u_n\right)$ est la suite définie pour $n\geq1$ par : $u_n=n-4$. -\item $\left(u_n\right)$ est la suite définie pour $n\geq3$ par : +\item $u$ est la suite définie pour $n\geq1$ par : \[\left\{\begin{array}{l} - u_3=-5\\ - \text{Pour tout $n\geq3$ : } u_{n+1}=\frac{ 4 }{ 5 }u_n. + u_1=-7\\ + \text{Pour tout $n\geq1$ : } u_{n+1}=\frac{ 1 }{ 5 }u_n. \end{array}\right.\] \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/Vf1SensEtTableau.0.answer b/data/ex/tests/Vf1SensEtTableau.0.answer index 947f946d..946fdf86 100644 --- a/data/ex/tests/Vf1SensEtTableau.0.answer +++ b/data/ex/tests/Vf1SensEtTableau.0.answer @@ -1,18 +1,20 @@ \exercice* \begin{enumerate} -\item la fonction $f$ est décroissante sur $[-5~;~-3]$ et $[-1~;~1]$ et $[2~;~5]$, croissante sur $[-3~;~-1]$ et $[1~;~2]$. +\item la fonction $f$ est décroissante sur $\interval{-3}{0}$ et $\interval{2}{3}$, croissante sur $\interval{-5}{-3}$ et $\interval{0}{2}$ et $\interval{3}{5}$. \item \begin{tabular}[t]{ll} \begin{tikzpicture}[scale=1] -\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$f\,(x)$/3}{$-5$,$-3$,$-1$,$1$,$2$,$5$} -\tkzTabVar{+/$4$,-/$0$,+/$3$,-/$1$,+/$2$,-/$-2$} -\tkzTabVal{5}{6}{0.5}{\scriptsize $3$}{$0$} +\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$f\,(x)$/3}{$-5$,$-3$,$0$,$2$,$3$,$5$} +\tkzTabVar{-/$2$,+/$4$,-/$-3$,+/$0$,-/$-4$,+/$-2$} +\tkzTabVal{2}{3}{0.5}{\scriptsize $-1$}{$0$} \end{tikzpicture} & \begin{tikzpicture}[scale=1] -\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$g\,(x)$/3}{$-5$,$-2$,$0$,$1$,$3$,$5$} -\tkzTabVar{+/$4$,+/$4$,-/$1$,+/$2$,-/$-4$,+/$-1$} -\tkzTabVal{4}{5}{0.5}{\scriptsize $2$}{$0$} +\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$g\,(x)$/3}{$-5$,$-2$,$0$,$3$,$5$} +\tkzTabVar{-/$-1$,+/$4$,+/$4$,-/$-4$,+/$1$} +\tkzTabVal{1}{2}{0.5}{\scriptsize $-4$}{$0$} +\tkzTabVal{3}{4}{0.5}{\scriptsize $2$}{$0$} +\tkzTabVal{4}{5}{0.5}{\scriptsize $4$}{$0$} \end{tikzpicture} \end{tabular} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/Vf1SensEtTableau.0.statement b/data/ex/tests/Vf1SensEtTableau.0.statement index 0a0d9507..45145d39 100644 --- a/data/ex/tests/Vf1SensEtTableau.0.statement +++ b/data/ex/tests/Vf1SensEtTableau.0.statement @@ -11,7 +11,7 @@ defaultpen(fontsize(9pt)); real[] xpt,ypt; real [] xpt={-5,-4,-3,-2,-1,00,01,02,03,04,05}; -real [] ypt={04,02,00,02,03,02,01,02,00,-1,-2}; +real [] ypt={02,03,04,01,00,-3,-1,00,-4,-3,-2}; xlimits(-6.2, 6.2); ylimits(-5.2, 5.2); xaxis(axis=BottomTop, p=invisible, @@ -30,7 +30,7 @@ ticks=Ticks(scale(.7)*Label(filltype=Fill(white)), Step=1, Size=3pt, end=false, endlabel=false, beginlabel=false, NoZero)); draw(graph(xpt,ypt,Hermite(monotonic)),brown+1.5); labelx(L=scale(.7)*"$0$", (0,0), align=SW); -label(L="$\mathcal{C}_f$", (-5,4), align=SW); +label(L="$\mathcal{C}_f$", (-5,2), align=NW); \end{asy} \kern1cm \begin{asy} @@ -40,7 +40,7 @@ label(L="$\mathcal{C}_f$", (-5,4), align=SW); defaultpen(fontsize(9pt)); real[] xpt,ypt; real [] xpt={-5,-4,-3,-2,-1,00,01,02,03,04,05}; -real [] ypt={04,04,04,04,03,01,02,00,-4,-2,-1}; +real [] ypt={-1,00,02,04,04,04,01,00,-4,00,01}; xlimits(-6.2, 6.2); ylimits(-5.2, 5.2); xaxis(axis=BottomTop, p=invisible, @@ -59,6 +59,6 @@ ticks=Ticks(scale(.7)*Label(filltype=Fill(white)), Step=1, Size=3pt, end=false, endlabel=false, beginlabel=false, NoZero)); draw(graph(xpt,ypt,Hermite(monotonic)),brown+1.5); labelx(L=scale(.7)*"$0$", (0,0), align=SW); -label(L="$\mathcal{C}_g$", (-5,4), align=SE); +label(L="$\mathcal{C}_g$", (-5,-1), align=NW); \end{asy} \end{center} \ No newline at end of file diff --git a/data/ex/tests/Vf2ExtremaGraphiques.0.answer b/data/ex/tests/Vf2ExtremaGraphiques.0.answer index eea286d5..bc11c867 100644 --- a/data/ex/tests/Vf2ExtremaGraphiques.0.answer +++ b/data/ex/tests/Vf2ExtremaGraphiques.0.answer @@ -2,18 +2,18 @@ \begin{enumerate} \item \begin{itemize}[leftmargin=*] -\item Sur $[-5~;~5]$ , le \textbf{maximum} de $f$ est $y = 4$. Il est \textbf{atteint en} $x = -5$. -\item Sur $[-5~;~5]$ , le \textbf{minimum} de $f$ est $y = -2$. Il est \textbf{atteint en} $x = 5$. +\item Sur $\interval{-5}{5}$ , le \textbf{maximum} de $f$ est $y = 4$. Il est \textbf{atteint en} $x = -3$. +\item Sur $\interval{-5}{5}$ , le \textbf{minimum} de $f$ est $y = -4$. Il est \textbf{atteint en} $x = 3$. \end{itemize} -\item Sur $[0~;~3]$, le \textbf{minimum} de $f$ est $y = 0$. Il est \textbf{atteint en} $x = 3$. +\item Sur $\interval{0}{2}$, le \textbf{minimum} de $f$ est $y = -3$. Il est \textbf{atteint en} $x = 0$. \item \begin{itemize}[leftmargin=*] -\item Sur $[-5~;~5]$ , le \textbf{maximum} de $g$ est $y = 4$. Il est \textbf{atteint en} $x = -5$. -\item Sur $[-5~;~5]$ , le \textbf{minimum} de $g$ est $y = -4$. Il est \textbf{atteint en} $x = 3$. +\item Sur $\interval{-5}{5}$ , le \textbf{maximum} de $g$ est $y = 4$. Il est \textbf{atteint en} $x = -2$. +\item Sur $\interval{-5}{5}$ , le \textbf{minimum} de $g$ est $y = -4$. Il est \textbf{atteint en} $x = 3$. \end{itemize} \item \begin{itemize}[leftmargin=*] -\item Sur $[-3~;~2]$ , le \textbf{maximum} de $g$ est $y = 4$. Il est \textbf{atteint en} $x = -3$. -\item Sur $[-3~;~2]$ , le \textbf{minimum} de $g$ est $y = 0$. Il est \textbf{atteint en} $x = 2$. +\item Sur $\interval{-2}{1}$ , le \textbf{maximum} de $g$ est $y = 4$. Il est \textbf{atteint en} $x = -2$. +\item Sur $\interval{-2}{1}$ , le \textbf{minimum} de $g$ est $y = 1$. Il est \textbf{atteint en} $x = 1$. \end{itemize} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/Vf2ExtremaGraphiques.0.statement b/data/ex/tests/Vf2ExtremaGraphiques.0.statement index 7b484abf..f802d3bc 100644 --- a/data/ex/tests/Vf2ExtremaGraphiques.0.statement +++ b/data/ex/tests/Vf2ExtremaGraphiques.0.statement @@ -2,9 +2,9 @@ \begin{multicols}{2} \begin{enumerate} \item Quels sont les extrema de la fonction $f$ ? -\item Quel est le minimum de $f$ sur l'intervalle $[0~;~3]$ ? +\item Quel est le minimum de $f$ sur l'intervalle $\interval{0}{2}$ ? \item Quels sont les extrema de la fonction $g$ ? -\item Quels sont les extrema de $g$ sur l'intervalle $[-3~;~2]$ ? +\item Quels sont les extrema de $g$ sur l'intervalle $\interval{-2}{1}$ ? \end{enumerate} \end{multicols} \begin{center} @@ -15,7 +15,7 @@ defaultpen(fontsize(9pt)); real[] xpt,ypt; real [] xpt={-5,-4,-3,-2,-1,00,01,02,03,04,05}; -real [] ypt={04,02,00,02,03,02,01,02,00,-1,-2}; +real [] ypt={02,03,04,01,00,-3,-1,00,-4,-3,-2}; xlimits(-6.2, 6.2); ylimits(-5.2, 5.2); xaxis(axis=BottomTop, p=invisible, @@ -34,7 +34,7 @@ ticks=Ticks(scale(.7)*Label(filltype=Fill(white)), Step=1, Size=3pt, end=false, endlabel=false, beginlabel=false, NoZero)); draw(graph(xpt,ypt,Hermite(monotonic)),brown+1.5); labelx(L=scale(.7)*"$0$", (0,0), align=SW); -label(L="$\mathcal{C}_f$", (-5,4), align=SW); +label(L="$\mathcal{C}_f$", (-5,2), align=NW); \end{asy} \kern1cm \begin{asy} @@ -44,7 +44,7 @@ label(L="$\mathcal{C}_f$", (-5,4), align=SW); defaultpen(fontsize(9pt)); real[] xpt,ypt; real [] xpt={-5,-4,-3,-2,-1,00,01,02,03,04,05}; -real [] ypt={04,04,04,04,03,01,02,00,-4,-2,-1}; +real [] ypt={-1,00,02,04,04,04,01,00,-4,00,01}; xlimits(-6.2, 6.2); ylimits(-5.2, 5.2); xaxis(axis=BottomTop, p=invisible, @@ -63,6 +63,6 @@ ticks=Ticks(scale(.7)*Label(filltype=Fill(white)), Step=1, Size=3pt, end=false, endlabel=false, beginlabel=false, NoZero)); draw(graph(xpt,ypt,Hermite(monotonic)),brown+1.5); labelx(L=scale(.7)*"$0$", (0,0), align=SW); -label(L="$\mathcal{C}_g$", (-5,4), align=SE); +label(L="$\mathcal{C}_g$", (-5,-1), align=NW); \end{asy} \end{center} \ No newline at end of file diff --git a/data/ex/tests/Vf3VariationVersCourbe.0.answer b/data/ex/tests/Vf3VariationVersCourbe.0.answer index 2b820119..23396df5 100644 --- a/data/ex/tests/Vf3VariationVersCourbe.0.answer +++ b/data/ex/tests/Vf3VariationVersCourbe.0.answer @@ -2,11 +2,11 @@ \begin{enumerate} \item \begin{enumerate} -\item La fonction $f$ est \textbf{négative} sur et \textbf{positive} sur $[-5~;~3]$. +\item La fonction $f$ est \textbf{négative} sur $\interval{-1}{5}$ et \textbf{positive} sur $\interval{-5}{-1}$. \item \begin{itemize}[leftmargin=*] -\item Sur $[-5~;~5]$ , le \textbf{maximum} de $g$ est $y = 4$. Il est \textbf{atteint en} $x = -5$. -\item Sur $[-5~;~5]$ , le \textbf{minimum} de $g$ est $y = -4$. Il est \textbf{atteint en} $x = 3$. +\item Sur $\interval{-5}{5}$ , le \textbf{maximum} de $g$ est $y = 4$. Il est \textbf{atteint en} $x = -2$. +\item Sur $\interval{-5}{5}$ , le \textbf{minimum} de $g$ est $y = -4$. Il est \textbf{atteint en} $x = 3$. \end{itemize} \end{enumerate} \item\ @@ -19,8 +19,8 @@ unitsize(5mm); defaultpen(fontsize(9pt)); real[] xpt,ypt; -real [] xpt={-5,-3,-1,01,02,03,05}; -real [] ypt={04,00,03,01,02,00,-2}; +real [] xpt={-5,-3,-1,00,02,03,05}; +real [] ypt={02,04,00,-3,00,-4,-2}; xlimits(-6.2, 6.2); ylimits(-5.2, 5.2); xaxis(axis=BottomTop, p=invisible, @@ -39,7 +39,7 @@ ticks=Ticks(scale(.7)*Label(filltype=Fill(white)), Step=1, Size=3pt, end=false, endlabel=false, beginlabel=false, NoZero)); draw(graph(xpt,ypt,Hermite(monotonic)),brown+1.5); labelx(L=scale(.7)*"$0$", (0,0), align=SW); -label(L="$\mathcal{C}_f$", (-5,4), align=SW); +label(L="$\mathcal{C}_f$", (-5,2), align=NW); \end{asy} \end{adjustbox} & @@ -50,8 +50,8 @@ label(L="$\mathcal{C}_f$", (-5,4), align=SW); unitsize(5mm); defaultpen(fontsize(9pt)); real[] xpt,ypt; -real [] xpt={-5,-2,00,01,02,03,05}; -real [] ypt={04,04,01,02,00,-4,-1}; +real [] xpt={-5,-4,-2,00,02,03,04,05}; +real [] ypt={-1,00,04,04,00,-4,00,01}; xlimits(-6.2, 6.2); ylimits(-5.2, 5.2); xaxis(axis=BottomTop, p=invisible, @@ -70,7 +70,7 @@ ticks=Ticks(scale(.7)*Label(filltype=Fill(white)), Step=1, Size=3pt, end=false, endlabel=false, beginlabel=false, NoZero)); draw(graph(xpt,ypt,Hermite(monotonic)),brown+1.5); labelx(L=scale(.7)*"$0$", (0,0), align=SW); -label(L="$\mathcal{C}_g$", (-5,4), align=SE); +label(L="$\mathcal{C}_g$", (-5,-1), align=NW); \end{asy} \end{adjustbox} \end{tabular} diff --git a/data/ex/tests/Vf3VariationVersCourbe.0.statement b/data/ex/tests/Vf3VariationVersCourbe.0.statement index 2c27ef6d..706f2187 100644 --- a/data/ex/tests/Vf3VariationVersCourbe.0.statement +++ b/data/ex/tests/Vf3VariationVersCourbe.0.statement @@ -12,15 +12,17 @@ \begin{center} \begin{tabular}[t]{ll} \begin{tikzpicture}[scale=1] -\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$f\,(x)$/3}{$-5$,$-3$,$-1$,$1$,$2$,$5$} -\tkzTabVar{+/$4$,-/$0$,+/$3$,-/$1$,+/$2$,-/$-2$} -\tkzTabVal{5}{6}{0.5}{\scriptsize $3$}{$0$} +\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$f\,(x)$/3}{$-5$,$-3$,$0$,$2$,$3$,$5$} +\tkzTabVar{-/$2$,+/$4$,-/$-3$,+/$0$,-/$-4$,+/$-2$} +\tkzTabVal{2}{3}{0.5}{\scriptsize $-1$}{$0$} \end{tikzpicture} & \begin{tikzpicture}[scale=1] -\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$g\,(x)$/3}{$-5$,$-2$,$0$,$1$,$3$,$5$} -\tkzTabVar{+/$4$,+/$4$,-/$1$,+/$2$,-/$-4$,+/$-1$} -\tkzTabVal{4}{5}{0.5}{\scriptsize $2$}{$0$} +\tkzTabInit[lgt=1.2,espcl=1.2]{$x$/1,$g\,(x)$/3}{$-5$,$-2$,$0$,$3$,$5$} +\tkzTabVar{-/$-1$,+/$4$,+/$4$,-/$-4$,+/$1$} +\tkzTabVal{1}{2}{0.5}{\scriptsize $-4$}{$0$} +\tkzTabVal{3}{4}{0.5}{\scriptsize $2$}{$0$} +\tkzTabVal{4}{5}{0.5}{\scriptsize $4$}{$0$} \end{tikzpicture} \end{tabular} \end{center} \ No newline at end of file diff --git a/data/ex/tests/Vf4ComparerImages.0.answer b/data/ex/tests/Vf4ComparerImages.0.answer index 184baef9..d68459b3 100644 --- a/data/ex/tests/Vf4ComparerImages.0.answer +++ b/data/ex/tests/Vf4ComparerImages.0.answer @@ -2,10 +2,10 @@ \begin{enumerate} \item \begin{enumerate} -\item $f\,(-4{,}9) > f\,(-4{,}4)$ car $-4{,}9 < -4{,}4$ et $f$ est décroissante sur $[-5~;~-4]$. -\item $f\,(4{,}2) < f\,(4{,}6)$ car $4{,}2 < 4{,}6$ et $f$ est croissante sur $[4~;~5]$. -\item $f\,(1{,}2) = f\,(1{,}6)$ car $1{,}2 < 1{,}6$ et $f$ est constante sur $[1~;~2]$. +\item $f\,(-6{,}7) > f\,(-6{,}3)$ car $-6{,}7 < -6{,}3$ et $f$ est décroissante sur $\interval{-7}{-6}$. +\item $f\,(2{,}9) < f\,(4{,}7)$ car $2{,}9 < 4{,}7$ et $f$ est croissante sur $\interval{2}{6}$. +\item $f\,(-5{,}8) = f\,(-5{,}3)$ car $-5{,}8 < -5{,}3$ et $f$ est constante sur $\interval{-6}{-5}$. \end{enumerate} -\item On ne peut pas comparer $f\,(-0{,}4)$ et $f\,(2{,}3)$ car la fonction $f$ n'est pas monotone (elle change de sens de variation) sur $[-0{,}4~;~2{,}3]$. -\item $f\,(4{,}8) > f\,(-4{,}5)$ car d’après le signe de la fonction $f\,(4{,}8) > 0$ et $f\,(-4{,}5) < 0$ (par contre, on ne peut pas utiliser le sens de variation qui change sur l’intervalle $[-4{,}5~;~4{,}8]$). +\item On ne peut pas comparer $f\,(-6{,}4)$ et $f\,(2{,}1)$ car la fonction $f$ n'est pas monotone (elle change de sens de variation) sur $\interval{-6{,}4}{2{,}1}$. +\item $f\,(4{,}1) < f\,(-2{,}7)$ car d’après le signe de la fonction $f\,(4{,}1) < 0$ et $f\,(-2{,}7) > 0$ (par contre, on ne peut pas utiliser le sens de variation qui change sur l’intervalle $\interval{-2{,}7}{4{,}1}$). \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/Vf4ComparerImages.0.statement b/data/ex/tests/Vf4ComparerImages.0.statement index 2c518849..657ec108 100644 --- a/data/ex/tests/Vf4ComparerImages.0.statement +++ b/data/ex/tests/Vf4ComparerImages.0.statement @@ -3,18 +3,20 @@ \item À partir du tableau de variation ci-dessous, recopier et compléter les égalités ou inégalités suivantes en justifiant :\vspace{-2ex} \begin{multicols}{3} \begin{enumerate} -\item $f\,(-4{,}9) \ldots{} f\,(-4{,}4)$ -\item $f\,(4{,}2) \ldots{} f\,(4{,}6)$ -\item $f\,(1{,}2) \ldots{} f\,(1{,}6)$ +\item $f\,(-6{,}7) \ldots{} f\,(-6{,}3)$ +\item $f\,(2{,}9) \ldots{} f\,(4{,}7)$ +\item $f\,(-5{,}8) \ldots{} f\,(-5{,}3)$ \end{enumerate}\vspace{-2ex} \end{multicols} -\item Peut-on comparer l’image des nombres $-0,4$ et $2,3$ ? Justifier. -\item Peut-on comparer l’image des nombres $4,8$ et $-4,5$ ? Justifier. +\item Peut-on comparer l’image des nombres $-6,4$ et $2,1$ ? Justifier. +\item Peut-on comparer l’image des nombres $4,1$ et $-2,7$ ? Justifier. \end{enumerate} \begin{center} \begin{tikzpicture}[scale=1] -\tkzTabInit[lgt=1.2,espcl=2]{$x$/1,$f\,(x)$/3}{$-5$,$-4$,$1$,$2$,$4$,$5$} -\tkzTabVar{+/$-3$,-/$-4$,+/$5$,+/$5$,-/$0$,+/$1$} -\tkzTabVal{2}{3}{0.5}{\scriptsize $-2$}{$0$} +\tkzTabInit[lgt=1.2,espcl=2]{$x$/1,$f\,(x)$/3}{$-7$,$-6$,$-5$,$-2$,$2$,$6$} +\tkzTabVar{+/$-5$,-/$-6$,-/$-6$,+/$3$,-/$-4$,+/$4$} +\tkzTabVal{3}{4}{0.5}{\scriptsize $-3$}{$0$} +\tkzTabVal{4}{5}{0.5}{\scriptsize $0$}{$0$} +\tkzTabVal{5}{6}{0.5}{\scriptsize $5$}{$0$} \end{tikzpicture} \end{center} \ No newline at end of file diff --git a/data/ex/tests/Vf5Extrema_Tableau.0.answer b/data/ex/tests/Vf5Extrema_Tableau.0.answer index 1a989380..fac433c6 100644 --- a/data/ex/tests/Vf5Extrema_Tableau.0.answer +++ b/data/ex/tests/Vf5Extrema_Tableau.0.answer @@ -3,14 +3,14 @@ \item \begin{multicols}{2} \begin{enumerate} -\item Pour $x \in [-9~;~4],\quad f\,(x) \ge -6$ -\item Pour $x \in [-9~;~4],\quad f\,(x) \le 3$ -\item Pour $x \in [-8{,}3~;~-5{,}2],\quad f\,(x) \ge -4$ +\item Pour $x \in \interval{-7}{6},\quad f\,(x) \geqslant{} -6$ +\item Pour $x \in \interval{-7}{6},\quad f\,(x) \leqslant{} 4$ +\item Pour $x \in \interval{-2{,}8}{1{,}6},\quad f\,(x) \geqslant{} -4$ \end{enumerate} \end{multicols} \item \begin{enumerate} -\item Sur $[-9~;~4],\quad -6 \le f\,(x) \le 3$. -\item Sur $[-8{,}6~;~-5{,}2],\quad -4 \le f\,(x) \le -3$. +\item Sur $\interval{-7}{6},\quad -6 \leqslant{} f\,(x) \leqslant{} 4$. +\item Sur $\interval{-2{,}7}{-1{,}5},\quad 0 \leqslant{} f\,(x) \leqslant{} 3$. \end{enumerate} \end{enumerate} \ No newline at end of file diff --git a/data/ex/tests/Vf5Extrema_Tableau.0.statement b/data/ex/tests/Vf5Extrema_Tableau.0.statement index 5084f8f5..5cea3bac 100644 --- a/data/ex/tests/Vf5Extrema_Tableau.0.statement +++ b/data/ex/tests/Vf5Extrema_Tableau.0.statement @@ -3,21 +3,23 @@ \item À partir du tableau de variation de la fonction $f$, compléter les égalités ou inégalités suivantes :\vspace{-2ex} \begin{multicols}{2} \begin{enumerate} -\item Pour $x \in [-9~;~4],\quad f\,(x) \ge \ldots{}$ -\item Pour $x \in [-9~;~4],\quad f\,(x) \le \ldots{}$ -\item Pour $x \in [-8{,}3~;~-5{,}2],\quad f\,(x) \ge \ldots{}$ +\item Pour $x \in \interval{-7}{6},\quad f\,(x) \geqslant{} \ldots{}$ +\item Pour $x \in \interval{-7}{6},\quad f\,(x) \leqslant{} \ldots{}$ +\item Pour $x \in \interval{-2{,}8}{1{,}6},\quad f\,(x) \geqslant{} \ldots{}$ \end{enumerate} \end{multicols} \item \begin{enumerate} -\item Donner un encadrement de la fonction $f$ sur l’intervalle $[-9~;~4]$. -\item Donner un encadrement de la fonction $f$ sur l’intervalle $[-8{,}6~;~-5{,}2]$. +\item Donner un encadrement de la fonction $f$ sur l’intervalle $\interval{-7}{6}$. +\item Donner un encadrement de la fonction $f$ sur l’intervalle $\interval{-2{,}7}{-1{,}5}$. \end{enumerate} \end{enumerate} \begin{center} \begin{tikzpicture}[scale=1] -\tkzTabInit[lgt=1.2,espcl=2]{$x$/1,$f\,(x)$/3}{$-9$,$-8$,$-5$,$-3$,$3$,$4$} -\tkzTabVar{+/$-3$,+/ \raisebox{-2.7cm}{}\raisebox{-1.5cm}{$-4$},+/ \raisebox{-2.7cm}{}\raisebox{-1.5cm}{$-4$},-/$-6$,+/$3$,-/$1$} -\tkzTabVal{4}{5}{0.5}{\scriptsize $1$}{$0$} +\tkzTabInit[lgt=1.2,espcl=2]{$x$/1,$f\,(x)$/3}{$-7$,$-6$,$-5$,$-2$,$2$,$6$} +\tkzTabVar{+/$-5$,-/$-6$,-/$-6$,+/$3$,-/$-4$,+/$4$} +\tkzTabVal{3}{4}{0.5}{\scriptsize $-3$}{$0$} +\tkzTabVal{4}{5}{0.5}{\scriptsize $0$}{$0$} +\tkzTabVal{5}{6}{0.5}{\scriptsize $5$}{$0$} \end{tikzpicture} \end{center} \ No newline at end of file diff --git a/data/ex/tests/exo_conversion_2d.0.answer b/data/ex/tests/exo_conversion_2d.0.answer index 2e0711da..d07f010a 100644 --- a/data/ex/tests/exo_conversion_2d.0.answer +++ b/data/ex/tests/exo_conversion_2d.0.answer @@ -5,27 +5,27 @@ Effectuer les conversions suivantes : \begin{multicols}{2}\noindent \begin{enumerate} -\item $\unit[86]{dam^2}=\unit[0,86]{hm^2}$\vspace{1ex}\par -\item $\unit[5,6]{dm^2}=\unit[0,000\,56]{dam^2}$\vspace{1ex}\par -\item $\unit[52,9]{cm^2}=\unit[0,005\,29]{m^2}$\vspace{1ex}\par -\item $\unit[35,4]{m^2}=\unit[0,003\,54]{hm^2}$\vspace{1ex}\par -\item $\unit[91,8]{dm^2}=\unit[918\,000]{mm^2}$\vspace{1ex}\par -\item $\unit[37,9]{cm^2}=\unit[0,379]{dm^2}$\vspace{1ex}\par +\item $\unit[96,5]{dam^2}=\unit[965\,000]{dm^2}$\vspace{1ex}\par +\item $\unit[59,8]{dam^2}=\unit[5\,980]{m^2}$\vspace{1ex}\par +\item $\unit[4,67]{dam^2}=\unit[0,046\,7]{hm^2}$\vspace{1ex}\par +\item $\unit[8,74]{dm^2}=\unit[87\,400]{mm^2}$\vspace{1ex}\par +\item $\unit[3,57]{dam^2}=\unit[0,000\,357]{km^2}$\vspace{1ex}\par +\item $\unit[8,48]{m^2}=\unit[848]{dm^2}$\vspace{1ex}\par \end{enumerate} \end{multicols} \begin{tabular}{*{13}{p{3.5mm}|}p{3.5mm}} \multicolumn{2}{c|}{$\rm km^2$} & \multicolumn{2}{c|}{$\rm hm^2$} & \multicolumn{2}{c|}{$\rm dam^2$} & \multicolumn{2}{c|}{$\rm m^2$} & \multicolumn{2}{c|}{$\rm dm^2$} & \multicolumn{2}{c|}{$\rm cm^2$} &\multicolumn{2}{c}{$\rm mm^2$}\\ \hline - & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{blue}{8}& \textcolor{blue}{6}\Rnode{virg0}{\ }& & & & & & & & + & & & & \textcolor{blue}{9}& \textcolor{blue}{6}\Rnode{virg0}{\ }& \textcolor{blue}{5}& \textcolor{red}{0}& \textcolor{red}{0}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& & & & \ncline{->}{virg0}{virg1} \\ - & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{5}\Rnode{virg0}{\ }& \textcolor{blue}{6}& & & + & & & & \textcolor{blue}{5}& \textcolor{blue}{9}\Rnode{virg0}{\ }& \textcolor{blue}{8}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& & & & & & \ncline{->}{virg0}{virg1} \\ - & & & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{5}& \textcolor{blue}{2}\Rnode{virg0}{\ }& \textcolor{blue}{9}& + & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{blue}{4}\Rnode{virg0}{\ }& \textcolor{blue}{6}& \textcolor{blue}{7}& & & & & & \ncline{->}{virg0}{virg1} \\ - & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{3}& \textcolor{blue}{5}\Rnode{virg0}{\ }& \textcolor{blue}{4}& & & & & + & & & & & & & & & \textcolor{blue}{8}\Rnode{virg0}{\ }& \textcolor{blue}{7}& \textcolor{blue}{4}& \textcolor{red}{0}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}} \ncline{->}{virg0}{virg1} \\ - & & & & & & & & \textcolor{blue}{9}& \textcolor{blue}{1}\Rnode{virg0}{\ }& \textcolor{blue}{8}& \textcolor{red}{0}& \textcolor{red}{0}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}} + & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{3}\Rnode{virg0}{\ }& \textcolor{blue}{5}& \textcolor{blue}{7}& & & & & & \ncline{->}{virg0}{virg1} \\ - & & & & & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{blue}{3}& \textcolor{blue}{7}\Rnode{virg0}{\ }& \textcolor{blue}{9}& + & & & & & & & \textcolor{blue}{8}\Rnode{virg0}{\ }& \textcolor{blue}{4}& {\textcolor{blue}{8}\Rnode{virg1}{\virgule}}& & & & \ncline{->}{virg0}{virg1} \\ \end{tabular} } \ No newline at end of file diff --git a/data/ex/tests/exo_conversion_2d.0.statement b/data/ex/tests/exo_conversion_2d.0.statement index f8248648..e6418804 100644 --- a/data/ex/tests/exo_conversion_2d.0.statement +++ b/data/ex/tests/exo_conversion_2d.0.statement @@ -2,11 +2,11 @@ Effectuer les conversions suivantes : \begin{multicols}{3}\noindent \begin{enumerate} -\item $\unit[86]{dam^2}=\unit[\dotfill]{hm^2}$ -\item $\unit[5,6]{dm^2}=\unit[\dotfill]{dam^2}$ -\item $\unit[52,9]{cm^2}=\unit[\dotfill]{m^2}$ -\item $\unit[35,4]{m^2}=\unit[\dotfill]{hm^2}$ -\item $\unit[91,8]{dm^2}=\unit[\dotfill]{mm^2}$ -\item $\unit[37,9]{cm^2}=\unit[\dotfill]{dm^2}$ +\item $\unit[96,5]{dam^2}=\unit[\dotfill]{dm^2}$ +\item $\unit[59,8]{dam^2}=\unit[\dotfill]{m^2}$ +\item $\unit[4,67]{dam^2}=\unit[\dotfill]{hm^2}$ +\item $\unit[8,74]{dm^2}=\unit[\dotfill]{mm^2}$ +\item $\unit[3,57]{dam^2}=\unit[\dotfill]{km^2}$ +\item $\unit[8,48]{m^2}=\unit[\dotfill]{dm^2}$ \end{enumerate} \end{multicols} \ No newline at end of file diff --git a/data/ex/tests/exo_conversion_3d.0.answer b/data/ex/tests/exo_conversion_3d.0.answer index 37cc39e0..c5910497 100644 --- a/data/ex/tests/exo_conversion_3d.0.answer +++ b/data/ex/tests/exo_conversion_3d.0.answer @@ -5,27 +5,27 @@ Effectuer les conversions suivantes : \begin{multicols}{2}\noindent \begin{enumerate} -\item $\unit[86]{dam^3}=\unit[0,086]{hm^3}$\vspace{1ex}\par -\item $\unit[5,6]{dm^3}=\unit[0,000\,005\,6]{dam^3}$\vspace{1ex}\par -\item $\unit[52,9]{cm^3}=\unit[0,000\,052\,9]{m^3}$\vspace{1ex}\par -\item $\unit[35,4]{m^3}=\unit[0,000\,035\,4]{hm^3}$\vspace{1ex}\par -\item $\unit[91,8]{dm^3}=\unit[91\,800\,000]{mm^3}$\vspace{1ex}\par -\item $\unit[37,9]{cm^3}=\unit[0,037\,9]{dm^3}$\vspace{1ex}\par +\item $\unit[96,5]{dam^3}=\unit[96\,500\,000]{dm^3}$\vspace{1ex}\par +\item $\unit[59,8]{dam^3}=\unit[59\,800]{m^3}$\vspace{1ex}\par +\item $\unit[4,67]{dam^3}=\unit[0,004\,67]{hm^3}$\vspace{1ex}\par +\item $\unit[8,74]{dm^3}=\unit[8\,740\,000]{mm^3}$\vspace{1ex}\par +\item $\unit[3,57]{dam^3}=\unit[0,000\,003\,57]{km^3}$\vspace{1ex}\par +\item $\unit[8,48]{m^3}=\unit[8\,480]{dm^3}$\vspace{1ex}\par \end{enumerate} \end{multicols} \begin{tabular}{*{20}{p{3.5mm}|}p{3.5mm}} \multicolumn{3}{c|}{$\rm km^3$} & \multicolumn{3}{c|}{$\rm hm^3$} & \multicolumn{3}{c|}{$\rm dam^3$} & \multicolumn{3}{c|}{$\rm m^3$} & \multicolumn{3}{c|}{$\rm dm^3$} & \multicolumn{3}{c|}{$\rm cm^3$} &\multicolumn{3}{c}{$\rm mm^3$}\\ \hline - & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{blue}{8}& \textcolor{blue}{6}\Rnode{virg0}{\ }& & & & & & & & & & & & + & & & & & & & \textcolor{blue}{9}& \textcolor{blue}{6}\Rnode{virg0}{\ }& \textcolor{blue}{5}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& & & & & & \ncline{->}{virg0}{virg1} \\ - & & & & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{5}\Rnode{virg0}{\ }& \textcolor{blue}{6}& & & & & + & & & & & & & \textcolor{blue}{5}& \textcolor{blue}{9}\Rnode{virg0}{\ }& \textcolor{blue}{8}& \textcolor{red}{0}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& & & & & & & & & \ncline{->}{virg0}{virg1} \\ - & & & & & & & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{5}& \textcolor{blue}{2}\Rnode{virg0}{\ }& \textcolor{blue}{9}& & + & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{4}\Rnode{virg0}{\ }& \textcolor{blue}{6}& \textcolor{blue}{7}& & & & & & & & & & \ncline{->}{virg0}{virg1} \\ - & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{3}& \textcolor{blue}{5}\Rnode{virg0}{\ }& \textcolor{blue}{4}& & & & & & & & + & & & & & & & & & & & & & & \textcolor{blue}{8}\Rnode{virg0}{\ }& \textcolor{blue}{7}& \textcolor{blue}{4}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}} \ncline{->}{virg0}{virg1} \\ - & & & & & & & & & & & & & \textcolor{blue}{9}& \textcolor{blue}{1}\Rnode{virg0}{\ }& \textcolor{blue}{8}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}} + & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{red}{0}& \textcolor{blue}{3}\Rnode{virg0}{\ }& \textcolor{blue}{5}& \textcolor{blue}{7}& & & & & & & & & & \ncline{->}{virg0}{virg1} \\ - & & & & & & & & & & & & & & {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& \textcolor{red}{0}& \textcolor{blue}{3}& \textcolor{blue}{7}\Rnode{virg0}{\ }& \textcolor{blue}{9}& & + & & & & & & & & & & & \textcolor{blue}{8}\Rnode{virg0}{\ }& \textcolor{blue}{4}& \textcolor{blue}{8}& {\textcolor{red}{0}\Rnode{virg1}{\virgule}}& & & & & & \ncline{->}{virg0}{virg1} \\ \end{tabular} } \ No newline at end of file diff --git a/data/ex/tests/exo_conversion_3d.0.statement b/data/ex/tests/exo_conversion_3d.0.statement index 37dd7714..422eedd5 100644 --- a/data/ex/tests/exo_conversion_3d.0.statement +++ b/data/ex/tests/exo_conversion_3d.0.statement @@ -2,11 +2,11 @@ Effectuer les conversions suivantes : \begin{multicols}{3}\noindent \begin{enumerate} -\item $\unit[86]{dam^3}=\unit[\dotfill]{hm^3}$ -\item $\unit[5,6]{dm^3}=\unit[\dotfill]{dam^3}$ -\item $\unit[52,9]{cm^3}=\unit[\dotfill]{m^3}$ -\item $\unit[35,4]{m^3}=\unit[\dotfill]{hm^3}$ -\item $\unit[91,8]{dm^3}=\unit[\dotfill]{mm^3}$ -\item $\unit[37,9]{cm^3}=\unit[\dotfill]{dm^3}$ +\item $\unit[96,5]{dam^3}=\unit[\dotfill]{dm^3}$ +\item $\unit[59,8]{dam^3}=\unit[\dotfill]{m^3}$ +\item $\unit[4,67]{dam^3}=\unit[\dotfill]{hm^3}$ +\item $\unit[8,74]{dm^3}=\unit[\dotfill]{mm^3}$ +\item $\unit[3,57]{dam^3}=\unit[\dotfill]{km^3}$ +\item $\unit[8,48]{m^3}=\unit[\dotfill]{dm^3}$ \end{enumerate} \end{multicols} \ No newline at end of file diff --git a/data/ex/tests/tex_units.0.answer b/data/ex/tests/tex_units.0.answer index 29ade2c3..d60c08dc 100644 --- a/data/ex/tests/tex_units.0.answer +++ b/data/ex/tests/tex_units.0.answer @@ -4,40 +4,40 @@ Effectuer les conversions suivantes : \begin{multicols}{2}\noindent \begin{enumerate} -\item 86~hm=8\,600~m\par +\item 96,5~km=9\,650~dam\par \begin{tabular}{c|c|c|c|c|c|c} km & hm & dam & m & dm & cm & mm \\ \hline -8 & 6\Rnode{virg0}{\ }& 0& {0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 0& 0& 0 +96\Rnode{virg0}{\ } & 5& {0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 0& 0& 0& 0 \end{tabular} \ncline{->}{virg0}{virg1} -\item 46,5~L=465~dL\par -\begin{tabular}{c|c|c|c|c|c} -hL & daL & L & dL & cL & mL \\ \hline -0 & 4& 6\Rnode{virg0}{\ }& {5\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 0& 0 +\item 62,4~dam=624~m\par +\begin{tabular}{c|c|c|c|c|c|c} +km & hm & dam & m & dm & cm & mm \\ \hline +0 & 6& 2\Rnode{virg0}{\ }& {4\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 0& 0& 0 \end{tabular} \ncline{->}{virg0}{virg1} -\item 91,7~dL=0,917~daL\par -\begin{tabular}{c|c|c|c|c|c} -hL & daL & L & dL & cL & mL \\ \hline -0 & {0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 9& 1\Rnode{virg0}{\ }& 7& 0 +\item 4,67~hg=46,7~dag\par +\begin{tabular}{c|c|c|c|c|c|c} +kg & hg & dag & g & dg & cg & mg \\ \hline +0 & 4\Rnode{virg0}{\ }& {6\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 7& 0& 0& 0 \end{tabular} \ncline{->}{virg0}{virg1} -\item 91,8~cg=0,091\,8~dag\par +\item 2,44~dag=244~dg\par \begin{tabular}{c|c|c|c|c|c|c} kg & hg & dag & g & dg & cg & mg \\ \hline -0 & 0& {0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 0& 9& 1\Rnode{virg0}{\ }& 8 +0 & 0& 2\Rnode{virg0}{\ }& 4& {4\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 0& 0 \end{tabular} \ncline{->}{virg0}{virg1} -\item 75,7~dag=0,757~kg\par +\item 8,23~km=823\,000~cm\par \begin{tabular}{c|c|c|c|c|c|c} -kg & hg & dag & g & dg & cg & mg \\ \hline -{0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}} & 7& 5\Rnode{virg0}{\ }& 7& 0& 0& 0 +km & hm & dam & m & dm & cm & mm \\ \hline +8\Rnode{virg0}{\ } & 2& 3& 0& 0& {0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 0 \end{tabular} \ncline{->}{virg0}{virg1} -\item 49,1~cg=0,491~g\par +\item 17,6~dm=0,001\,76~km\par \begin{tabular}{c|c|c|c|c|c|c} -kg & hg & dag & g & dg & cg & mg \\ \hline -0 & 0& 0& {0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}}& 4& 9\Rnode{virg0}{\ }& 1 +km & hm & dam & m & dm & cm & mm \\ \hline +{0\Rnode{virg1}{\textcolor{red}{ \LARGE ,}}} & 0& 0& 1& 7\Rnode{virg0}{\ }& 6& 0 \end{tabular} \ncline{->}{virg0}{virg1} \end{enumerate} diff --git a/data/ex/tests/tex_units.0.statement b/data/ex/tests/tex_units.0.statement index 6b956c01..960d7b30 100644 --- a/data/ex/tests/tex_units.0.statement +++ b/data/ex/tests/tex_units.0.statement @@ -2,11 +2,11 @@ Effectuer les conversions suivantes : \begin{multicols}{3}\noindent \begin{enumerate} -\item 86~hm=\dotfill~m -\item 46,5~L=\dotfill~dL -\item 91,7~dL=\dotfill~daL -\item 91,8~cg=\dotfill~dag -\item 75,7~dag=\dotfill~kg -\item 49,1~cg=\dotfill~g +\item 96,5~km=\dotfill~dam +\item 62,4~dam=\dotfill~m +\item 4,67~hg=\dotfill~dag +\item 2,44~dag=\dotfill~dg +\item 8,23~km=\dotfill~cm +\item 17,6~dm=\dotfill~km \end{enumerate} \end{multicols} \ No newline at end of file diff --git a/debian/control b/debian/control index c22d0e83..ee96a5d5 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Homepage: http://www.pyromaths.org/ Package: pyromaths Architecture: all -Depends: ${python:Depends}, ${misc:Depends}, python-jinja2, python-qt4, python-lxml, texlive-pstricks, texlive-latex-base, texlive-latex-extra, texlive-fonts-recommended, texlive-latex-recommended, latexmk, asymptote, texlive-pictures, texlive-lang-french +Depends: ${python:Depends}, ${misc:Depends}, python-jinja2, python-qt5, python-lxml, texlive-pstricks, texlive-latex-base, texlive-latex-extra, texlive-fonts-recommended, texlive-latex-recommended, latexmk, asymptote, texlive-pictures, texlive-lang-french Description: Exerciseur de mathématiques créant des fiches LaTeX Pyromaths est un programme qui a pour but de créer des exercices type de mathématiques niveau collège et lycée ainsi que leur corrigé. C'est diff --git a/pyromaths b/pyromaths index df259b17..a71126de 100755 --- a/pyromaths +++ b/pyromaths @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 try: from pyromaths import pyromaths except ImportError: diff --git a/setup.py b/setup.py index 8157c6bb..268b577d 100755 --- a/setup.py +++ b/setup.py @@ -10,21 +10,21 @@ may be operated by other scripts (see: pkg/README). Python source and bynary eggs (all platforms): - $ python setup.py [sdist|bdist|bdist_egg] [options...] + $ python3 setup.py [sdist|bdist|bdist_egg] [options...] RPM package (UNIX/Linux): $ ./setup.py bdist_rpm [options...] Self-contained application (Mac OS X): - $ python setup.py py2app [options...] + $ python3 setup.py py2app [options...] Self-contained application (Windows): - $ python setup.py py2exe [options...] - $ python setup.py innosetup [options...] + $ python3 setup.py py2exe [options...] + $ python3 setup.py innosetup [options...] Help and options: - $ python setup.py --help - $ python setup.py --help-commands + $ python3 setup.py --help + $ python3 setup.py --help-commands Created on 13 avr. 2013 @author: Olivier Cornu diff --git a/src/pyromaths.py b/src/pyromaths.py index f88b5b3e..e81c4d1d 100644 --- a/src/pyromaths.py +++ b/src/pyromaths.py @@ -1,2 +1,3 @@ +from __future__ import unicode_literals from pyromaths import pyromaths pyromaths.main() diff --git a/src/pyromaths/Values.py b/src/pyromaths/Values.py index dbe0997d..ff72676d 100644 --- a/src/pyromaths/Values.py +++ b/src/pyromaths/Values.py @@ -1,13 +1,16 @@ -#!/usr/bin/python +#! /usr/bin/env python3 # -*- coding: utf-8 -*- # +from __future__ import absolute_import +from __future__ import unicode_literals +from builtins import str from time import strftime from os.path import normpath, dirname, exists, abspath, join from os import environ, name from sys import executable, getfilesystemencoding import sys # import pkgutil, types -import ex +from . import ex def we_are_frozen(): """Returns whether we are frozen via py2exe. @@ -22,7 +25,7 @@ def data_dir(): path = 'data' elif sys.platform == 'darwin': path = '../Resources/data' - return join(normpath(dirname(unicode(executable, + return join(normpath(dirname(str(executable, getfilesystemencoding()))), path) # We're alive # Are we running from the sources? @@ -43,19 +46,18 @@ def icon_dir(): if name == 'nt': def home(): - return unicode(environ['USERPROFILE'], getfilesystemencoding()) + return environ['USERPROFILE'] def configdir(): - return join(unicode(environ['APPDATA'], getfilesystemencoding()), - "pyromaths") + return join(environ['APPDATA'], "pyromaths") elif sys.platform == "darwin": # Cas de Mac OS X. def home(): - return unicode(environ['HOME'], getfilesystemencoding()) + return environ['HOME'] def configdir(): return join(home(), "Library", "Application Support", "Pyromaths") else: def home(): try: - return unicode(environ['HOME'], getfilesystemencoding()) + return environ['HOME'] except KeyError: # Pyromaths en ligne, l'user apache n'a pas de $HOME return "" @@ -76,6 +78,6 @@ def configdir(): def lesfiches(): """Charge et renvoie les fiches d'exercices""" fiches = [] - for level, exercices in ex.load_levels().iteritems(): + for level, exercices in list(ex.load_levels().items()): fiches.append([level, '', exercices]) return fiches diff --git a/src/pyromaths/__init__.py b/src/pyromaths/__init__.py index 214ed1f1..914a119e 100644 --- a/src/pyromaths/__init__.py +++ b/src/pyromaths/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths diff --git a/src/pyromaths/classes/Fractions.py b/src/pyromaths/classes/Fractions.py index 2ff002a2..5aae1248 100644 --- a/src/pyromaths/classes/Fractions.py +++ b/src/pyromaths/classes/Fractions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,13 +21,22 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from future import standard_library +standard_library.install_aliases() +from builtins import str +from builtins import range +from builtins import object +from past.utils import old_div from pyromaths.outils.Arithmetique import pgcd, ppcm from collections import Counter from pyromaths.classes.SquareRoot import SquareRoot from pyromaths.outils.Priorites3 import EstNombre, texify -from __builtin__ import str +from builtins import str +from functools import reduce -class Fraction(): +class Fraction(object): """Cette classe crée la notion de fractions. code permet de préciser si une décomposition a pour objectif une mise au même dénominateur 'r' ou une simplification 's' @@ -247,7 +256,7 @@ def choix_denominateur(self, denominateur): Écrit la fraction self avec le dénominateur denominateur """ if denominateur != self.d: - return Fraction("%s*%s" % (self.n, denominateur / self.d), "%s*%s" % (self.d, denominateur / self.d), "r") + return Fraction("%s*%s" % (self.n, old_div(denominateur, self.d)), "%s*%s" % (self.d, old_div(denominateur, self.d)), "r") else: return self @@ -433,7 +442,7 @@ def __mul__(self, *others): lepgcdtmp = pgcd(lnum[i], lepgcd) if lepgcdtmp != 1: num.append("%r*%r" % (lepgcdtmp, lnum[i] // lepgcdtmp)) else: num.append("%r" % lnum[i]) - lepgcd = lepgcd / lepgcdtmp + lepgcd = old_div(lepgcd, lepgcdtmp) i += 1 i, lepgcd = 0, s while i < len(lden): @@ -444,7 +453,7 @@ def __mul__(self, *others): lepgcdtmp = pgcd(lden[i], lepgcd) if lepgcdtmp != 1: den.append("%r*%r" % (lepgcdtmp, lden[i] // lepgcdtmp)) else: den.append("%r" % lden[i]) - lepgcd = lepgcd / lepgcdtmp + lepgcd = old_div(lepgcd, lepgcdtmp) i += 1 num, den = "*".join(num), "*".join(den) while num[:2] == "1*": num = num[2:] @@ -478,7 +487,7 @@ def __rmul__(self, other): return Fraction(other) * self # def __truediv__(self, fraction): # pour Python 3 - def __div__(self, other): + def __truediv__(self, other): """*object*\ .\ **__div__**\ (*other*) ``p.__div__(q)`` est équivalent à ``p / q`` calcule le quotient de deux fractions. @@ -499,10 +508,10 @@ def __div__(self, other): other = Fraction(other) return "%r*%r" % (self, ~other) - def __rdiv__(self, other): - """*object*\ .\ **__rdiv__**\ (*other*) + def __rtruediv__(self, other): + """*object*\ .\ **__rtruediv__**\ (*other*) - ``p.__rdiv__(q)`` est équivalent à ``p / q`` calcule le produit de l'objet p par la fraction q. + ``p.__rtruediv__(q)`` est équivalent à ``p / q`` calcule le produit de l'objet p par la fraction q. *other* peut être un entier ou un réel. @@ -566,12 +575,13 @@ def __trunc__(self): return self.n // self.d def __lt__(self, other): + print(repr(self), other) if isinstance(other, int) or isinstance(other, float): other = Fraction(other) - if other.d * self.d > 0: - return self.n * other.d < self.d * other.n + if other.traitement().d * self.traitement().d > 0: + return self.traitement().n * other.traitement().d < self.traitement().d * other.traitement().n else : - return not(self.n * other.d < self.d * other.n) + return not(self.traitement().n * other.traitement().d < self.traitement().d * other.traitement().n) def __le__(self, other): if isinstance(other, int) or isinstance(other, float): @@ -609,11 +619,12 @@ def __ge__(self, other): return not(self.n * other.d >= self.d * other.n) def __float__(self): - return 1.0 * self.n / self.d + f = self.traitement() + return f.n/f.d def __int__(self): assert self.n % self.d == 0, "La fraction n'est pas un nombre entier !" - return int(self.n / self.d) + return int(old_div(self.n, self.d)) def reduit(self): """**reduit**\ (*object*) diff --git a/src/pyromaths/classes/Polynome.py b/src/pyromaths/classes/Polynome.py index 49a8a7a8..2b58e89f 100644 --- a/src/pyromaths/classes/Polynome.py +++ b/src/pyromaths/classes/Polynome.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,12 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from builtins import object +from past.utils import old_div if __name__ == "__main__": import sys, os sys.path.append(os.path.join('..')) @@ -33,7 +39,7 @@ # from pyromaths.outils.Affichage import pTeX, TeX, radicalTeX, fTeX, Fractions, tTeX from pyromaths.outils.Affichage import TeX, tTeX -class Polynome: +class Polynome(object): '''Classe de polynôme pour le lycee''' def __init__(self, liste_coeff, var="x"): self.var = var # Lettre pour la var @@ -44,7 +50,7 @@ def __init__(self, liste_coeff, var="x"): liste_coeff = dict((i, liste_coeff[i])for i in range(len(liste_coeff))) elif isinstance(liste_coeff, int) or isinstance(liste_coeff, Fraction) or isinstance(liste_coeff, float): liste_coeff = {0:liste_coeff} - for i in liste_coeff.iterkeys(): + for i in list(liste_coeff.keys()): if liste_coeff[i] != 0: if isinstance(liste_coeff[i], (RacineDegre2, Fraction)): #=========================================================== @@ -56,7 +62,7 @@ def __init__(self, liste_coeff, var="x"): if liste_reduite == {} or liste_coeff == []: liste_reduite = {0:0} self.dictio = liste_reduite - self.puiss = liste_reduite.keys() + self.puiss = list(liste_reduite.keys()) self.puiss.sort(reverse=True) self.deg = self.degre() self.degre_max = max(0, self.deg) @@ -66,7 +72,7 @@ def __len__(self): def degre(self): degre = float("-inf") - for i in self.dictio.iterkeys(): + for i in list(self.dictio.keys()): if i > degre and self.dictio[i] != 0: degre = i return degre @@ -147,8 +153,8 @@ def __add__(self, other): def __mul__(self, other): if isinstance(other, Polynome): result = Polynome({0:0}, var=self.var) - for i in self.dictio.iterkeys(): - for j in other.dictio.iterkeys(): + for i in list(self.dictio.keys()): + for j in list(other.dictio.keys()): exposant = i + j coefficient = self.dictio[i] * other.dictio[j] result = result + Polynome({exposant:coefficient}, var=self.var) @@ -171,7 +177,7 @@ def __eq__(self, other): def __pow__(self, other): if isinstance(other, int) and other >= 0: result = Polynome({0:1}, self.var) - for dummy in xrange(other): + for dummy in range(other): result *= self return result @@ -192,18 +198,18 @@ def __neg__(self): def __rmul__(self, nombre): return self * Polynome({0:nombre}) - def __div__(self, other): + def __truediv__(self, other): if isinstance(other, int): return Fraction(1, other) * self elif isinstance(other, Fraction) or isinstance(other, float)or isinstance(other, RacineDegre2): - return (1 / other) * self + return (old_div(1, other)) * self else: quotient = Polynome({}, var=self.var) reste = self diviseur_degre = other.deg while diviseur_degre <= reste.deg: ajout_quotient_deg = reste.deg - diviseur_degre - facteur = reste.dictio[reste.deg] / other.dictio[other.deg] + facteur = old_div(reste.dictio[reste.deg], other.dictio[other.deg]) ajout_quotient = Polynome({ajout_quotient_deg:facteur}, var=self.var) quotient = quotient + ajout_quotient soustrait_reste = ajout_quotient * other @@ -231,7 +237,7 @@ def __call__(self, x,): return self.TeX(var=x) else: result = 0 - for i in self.dictio.iterkeys(): + for i in list(self.dictio.keys()): result = result + self[i] * x ** i if isinstance(result, str): result = eval(Priorites3.priorites(result)[-1][0]) @@ -259,11 +265,11 @@ def racine_evidente(self, liste=[-2, -1, 0, 1, 2]): def factorise(self, TeX=False, racines=[0, -1, 1, 2, -2]): facteurs = [Polynome({0:self.dictio[self.deg]}, var=self.var)] - developpe, reste = self / facteurs[0] + developpe, reste = old_div(self, facteurs[0]) for r in racines: while developpe(r) == 0: rac = -r - developpe, reste = developpe / Polynome({1:1, 0:rac}, var=self.var) + developpe, reste = old_div(developpe, Polynome({1:1, 0:rac}, var=self.var)) facteurs = facteurs + [Polynome({1:1, 0:rac})] if TeX: stringTeX = "" @@ -283,7 +289,7 @@ def factorise(self, TeX=False, racines=[0, -1, 1, 2, -2]): def derive(self): result = {} - for i in self.dictio.iterkeys(): + for i in list(self.dictio.keys()): if i == 0: result[0] = 0 else: @@ -291,7 +297,7 @@ def derive(self): return Polynome(result, self.var) def primitive(self): result = {} - for i in self.dictio.iterkeys(): + for i in list(self.dictio.keys()): result[i + 1] = Fraction(1, int(i + 1)) * self.dictio[i] return Polynome(result, self.var) diff --git a/src/pyromaths/classes/PolynomesCollege.py b/src/pyromaths/classes/PolynomesCollege.py index 337ce881..3ea4e68e 100644 --- a/src/pyromaths/classes/PolynomesCollege.py +++ b/src/pyromaths/classes/PolynomesCollege.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,14 +20,21 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div +from builtins import object from pyromaths.outils.decimaux import decimaux from pyromaths.outils import Priorites3 from pyromaths.classes.SquareRoot import SquareRoot from pyromaths.classes.Fractions import Fraction from random import * +from functools import reduce -class Polynome(): +class Polynome(object): """ Cette classe crée la notion de polynômes. Si ``var == None`` alors la variable est ``x``. @@ -57,7 +64,7 @@ def __init__(self, monomes, var=None, details=0): self.monomes = monomes.monomes self.var = monomes.var self.details = monomes.details - elif isinstance(monomes, basestring): + elif isinstance(monomes, str): # Gère la construction des polynôme à partir d'une chaîne de caractères self.details = details listmonomes = [] @@ -337,7 +344,7 @@ def __add__(self, *others): :type: Polynome ou string *évaluable comme Polynome* :rtype: Polynome """ -# if isinstance(other, basestring): +# if isinstance(other, str): # other = eval(other) for other in others: other = self._convert_other(other) @@ -358,7 +365,7 @@ def __radd__(self, other): :type: Polynome ou string *évaluable comme Polynome* :rtype: Polynome """ - if isinstance(other, basestring): + if isinstance(other, str): other = eval(other) other = self._convert_other(other) return other + self @@ -679,7 +686,7 @@ def __rmul__(self, other): def _divide(self, other): """*object*\ .\ **div**\ (*other*) - ``p.__div__(q)`` est équivalent à ``p / q`` + ``p.__truediv__(q)`` est équivalent à ``p / q`` Renvoie (self // other, self % other) deux polynomes où le premier élément est le quotient et le second le reste de la division euclidienne de self par other. @@ -1055,7 +1062,7 @@ def id_rem(poly): elif len(poly) == 3: a = repr(Polynome([[sqrt(abs(poly[0][0])), poly[0][1] // 2]], poly.var, poly.details)) b = repr(Polynome([[sqrt(abs(poly[2][0])), poly[2][1] // 2]], poly.var, poly.details)) - if not poly[0][1] % 2 and not poly[2][1] % 2 and (poly[0][1] / 2 + poly[2][1] / 2 == poly[1][1]): + if not poly[0][1] % 2 and not poly[2][1] % 2 and (old_div(poly[0][1], 2) + old_div(poly[2][1], 2) == poly[1][1]): # Ça ressemble à l'une des deux premières indentités remarquables if poly[0][0] * poly[2][0] > 0 and poly[0][0] * poly[1][0] > 0 and \ 4 * poly[0][0] * poly[2][0] == poly[1][0] ** 2: diff --git a/src/pyromaths/classes/Racine.py b/src/pyromaths/classes/Racine.py index cf9f041b..7bb5dffd 100644 --- a/src/pyromaths/classes/Racine.py +++ b/src/pyromaths/classes/Racine.py @@ -1,9 +1,17 @@ # -*- coding: utf-8 -*- +from __future__ import print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from builtins import object +from past.utils import old_div from pyromaths.outils.decimaux import decimaux from pyromaths.outils.Arithmetique import carrerise, pgcd, ppcm, factor from math import sqrt -from Fractions import Fraction +from .Fractions import Fraction def produitfacteurs(facteurs): """Affiche sous forme de produit les éléments d'une liste.""" @@ -12,10 +20,10 @@ def produitfacteurs(facteurs): prodfacteurs += str(element) + ' \\times ' return prodfacteurs[:-7] -class Racine: +class Racine(object): def __init__(self, radicande, coeff=1, indice=2): if (radicande < 0) or not (isinstance(indice, int)): - print "Erreur de définition ! Le radicande doit être positif et l'indice un nombre entier !" + print("Erreur de définition ! Le radicande doit être positif et l'indice un nombre entier !") self.radicande = radicande self.indice = indice # Nombre entier self.coeff = coeff # Coeff devant la racine @@ -53,19 +61,19 @@ def __mul__(self, other): def __rmul__(self, other): return self * other - def __div__(self, other): + def __truediv__(self, other): if (isinstance(other, float)) or (isinstance(other, int)): - return Racine(self.radicande, self.coeff / other, self.indice) + return Racine(self.radicande, old_div(self.coeff, other), self.indice) elif self.indice == other.indice: - return Racine(self.radicande / float(other.radicande), self.coeff / float(other.coeff), self.indice) + return Racine(old_div(self.radicande, float(other.radicande)), old_div(self.coeff, float(other.coeff)), self.indice) else: return str(self) + ' / ' + str(other) - def __rdiv__(self, other): + def __rtruediv__(self, other): if (isinstance(other, float)) or (isinstance(other, int)): - return Racine(self.radicande, other / float(self.coeff * self.radicande), self.indice) + return Racine(self.radicande, old_div(other, float(self.coeff * self.radicande)), self.indice) elif self.indice == other.indice: - return Racine(other.radicande / float(self.radicande), other.coeff / float(self.coeff), self.indice) + return Racine(old_div(other.radicande, float(self.radicande)), old_div(other.coeff, float(self.coeff)), self.indice) else: return str(other) + ' / ' + str(self) @@ -141,7 +149,7 @@ def tTeX(n): -class RacineDegre2: +class RacineDegre2(object): def __init__(self, numerateur=0, denominateur=1, coeff=1, radicande=0): """Constructeur de la forme (a+c*racine(d))/b""" self.numerateur = numerateur # a @@ -238,8 +246,8 @@ def __add__(self, other): return NotImplemented denominateur = ppcm(premier.denominateur, second.denominateur) - facteur1 = denominateur / premier.denominateur - facteur2 = denominateur / second.denominateur + facteur1 = old_div(denominateur, premier.denominateur) + facteur2 = old_div(denominateur, second.denominateur) # if self.radicande==other.radicande: coeff = premier.coeff * facteur1 * (premier.radicande != 0) + second.coeff * facteur2 * (second.radicande != 0) if coeff == 0: @@ -281,9 +289,9 @@ def __mul__(self, other): radicande) def __invert__(self): return self.denominateur * RacineDegre2(self.numerateur, self.numerateur ** 2 - self.coeff ** 2 * self.radicande, -self.coeff, self.radicande) - def __div__(self, other): + def __truediv__(self, other): return self * ~other - def __rdiv__(self, other): + def __rtruediv__(self, other): return ~self * other def __rmul__(self, other): return self * other @@ -293,12 +301,20 @@ def __pow__(self, n): result = result * self return result def __float__(self): - return (self.numerateur + self.coeff * sqrt(self.radicande)) / self.denominateur - def __cmp__(self, other): - comp = float(self) - float(other) - if comp > 0: - return 1 - elif comp < 0: - return -1 - else: - return 0 \ No newline at end of file + return old_div((self.numerateur + self.coeff * sqrt(self.radicande)), self.denominateur) + def __lt__(self, other): + if float(self) - float(other) < 0: return True + else: return False + def __eq__(self, other): + return float(self) == float(other) + def __ne__(self, other): + return not self == other + def __gt__(self, other): + if float(self) - float(other) > 0: return True + else: return False + def __ge__(self, other): + if float(self) - float(other) >= 0: return True + else: return False + def __le__(self, other): + if float(self) - float(other) <= 0: return True + else: return False diff --git a/src/pyromaths/classes/SecondDegre.py b/src/pyromaths/classes/SecondDegre.py deleted file mode 100644 index bcb9a81b..00000000 --- a/src/pyromaths/classes/SecondDegre.py +++ /dev/null @@ -1,71 +0,0 @@ -# -*- coding: utf-8 -*- - -# import random -# from pyromaths.outils.Arithmetique import factorise, carrerise -# from math import sqrt -from pyromaths.outils.decimaux import suppr0 - -class Poly2: - """Classe pour les polynômes du second degré.""" - def __init__(self, a, b, c): - assert a != 0, u"Erreur de définition ! a doit être différent de 0." - self.a = a - self.b = b - self.c = c - self.delta = suppr0(b ** 2 - 4 * a * c) - if self.delta > 0: - self.signedelta = "strictement positif" - self.nbrac = 2 - elif self.delta < 0: - self.signedelta = "strictement négatif" - self.nbrac = 0 - else: - self.signedelta = "nul" - self.nbrac = 1 - - def __add__(self, other): - return Poly2(self.a + other.a, self.b + other.b, self.c + other.c) - - def __radd__(self, other): - return Poly2(self.a + other.a, self.b + other.b, self.c + other.c) - - def __sub__(self, other): - return Poly2(self.a - other.a, self.b - other.b, self.c - other.c) - - def __rsub__(self, other): - return Poly2(self.a - other.a, self.b - other.b, self.c - other.c) - - def __str__(self): - if self.b <= 0: - sep1 = '' - else: - sep1 = '+' - if self.c <= 0: - sep2 = '' - else: - sep2 = '+' - if self.a == 1: - a1 = '' - else: - a1 = str(suppr0(self.a)) - if self.b == 1: - b1 = '' - else: - b1 = str(suppr0(self.b)) - if self.b == 0: - deg1 = '' - b1 = '' - else: - deg1 = 'x' - return a1 + 'x^2' + sep1 + b1 + deg1 + sep2 + str(suppr0(self.c)) - - def print_signe(self, signe): - return str(self) + " " + signe + " 0" - - def __repr__(self): - return "{}({}, {}, {})".format( - self.__class__.__name__, - repr(self.a), - repr(self.b), - repr(self.c), - ) diff --git a/src/pyromaths/classes/SquareRoot.py b/src/pyromaths/classes/SquareRoot.py index 007129df..1c2f5322 100644 --- a/src/pyromaths/classes/SquareRoot.py +++ b/src/pyromaths/classes/SquareRoot.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -26,13 +26,19 @@ @author: jerome ''' +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from builtins import object +from past.utils import old_div from pyromaths.outils.Arithmetique import carrerise from pyromaths.outils.decimaux import decimaux from pyromaths.outils import Priorites3 from pyromaths import classes from math import sqrt -class SquareRoot(): +class SquareRoot(object): ''' Définit la classe SquareRoot permettant de manipuler des racines carrées. @@ -383,7 +389,7 @@ def Decompose(self): return '%r*%r' % (racine[0], int(sqrt(racine[1]))) if complement == racine[1]: return repr(self) - return '%r*%r' % (SquareRoot([racine[0], racine[1] / complement]), SquareRoot([1, complement])) + return '%r*%r' % (SquareRoot([racine[0], old_div(racine[1], complement)]), SquareRoot([1, complement])) raise ValueError(u'Not Implemented : SquareRoot(%s)' % racine) def simplifie(self): diff --git a/src/pyromaths/classes/Vecteurs.py b/src/pyromaths/classes/Vecteurs.py index f7656997..ec817a30 100644 --- a/src/pyromaths/classes/Vecteurs.py +++ b/src/pyromaths/classes/Vecteurs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -22,11 +22,17 @@ # +from __future__ import absolute_import +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import object +from past.utils import old_div import math import random -from Racine import simplifie_racine +from .Racine import simplifie_racine -class Vecteur: +class Vecteur(object): def __init__(self, x=0, y=0): self.x = x @@ -57,9 +63,9 @@ def __neg__(self): '''Négatif d'un vecteur''' return -1 * self - def __div__(self, c): + def __truediv__(self, c): if isinstance(c, float) or isinstance(c, int): - return Vecteur(self.x / float(c), self.y / float(c)) + return Vecteur(old_div(self.x, float(c)), old_div(self.y, float(c))) def __abs__(self): '''Retourne la norme du vecteur sous la forme coeff,radicande où sqrt(n)=coeff*sqrt(radicande)''' diff --git a/src/pyromaths/classes/__init__.py b/src/pyromaths/classes/__init__.py index 214ed1f1..914a119e 100644 --- a/src/pyromaths/classes/__init__.py +++ b/src/pyromaths/classes/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths diff --git a/src/pyromaths/cli/__init__.py b/src/pyromaths/cli/__init__.py index 65e03e01..042ce71b 100644 --- a/src/pyromaths/cli/__init__.py +++ b/src/pyromaths/cli/__init__.py @@ -17,6 +17,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """Generic stuff for pyromaths command line interface""" +from __future__ import unicode_literals import argparse diff --git a/src/pyromaths/cli/__main__.py b/src/pyromaths/cli/__main__.py index 5d1c234e..fdd01e3b 100755 --- a/src/pyromaths/cli/__main__.py +++ b/src/pyromaths/cli/__main__.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (C) 2016-2018 -- Louis Paternault (spalax@gresille.org) @@ -21,8 +21,10 @@ To display help: -> python -m pyromaths.cli --help +> python3 -m pyromaths.cli --help """ +from __future__ import print_function +from __future__ import unicode_literals import argparse import gettext @@ -30,8 +32,17 @@ import random import sys +from os.path import join, dirname, realpath +import gettext + +locale_dir = join(dirname(__file__), '../../../locale/') +locale_dir = realpath(locale_dir) + +gettext.bindtextdomain('pyromaths', locale_dir) +gettext.textdomain('pyromaths') +_ = gettext.gettext # Quick and dirty definition of `_` as the identity function -gettext.install('pyromaths', unicode=1) +#gettext.install('pyromaths') from pyromaths.cli import exercise_argument, PyromathsException from pyromaths.ex.test import TestPerformer, generate @@ -154,7 +165,7 @@ def do_generate(options): exercise_list = [] for exercise, seeds in options.exercise: if not seeds: - seeds = [random.randint(0, sys.maxint)] + seeds = [random.randint(0, sys.maxsize)] for seed in seeds: exercise_list.append(tests.get(exercise, seed).get_exercise()) diff --git a/src/pyromaths/cli/dummy.py b/src/pyromaths/cli/dummy.py index cf63ed3f..845b6e02 100644 --- a/src/pyromaths/cli/dummy.py +++ b/src/pyromaths/cli/dummy.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (C) 2018 -- Louis Paternault (spalax@gresille.org) @@ -18,6 +18,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """Création d'un modèle d'exercice.""" +from __future__ import unicode_literals import logging import os diff --git a/src/pyromaths/cli/test/__main__.py b/src/pyromaths/cli/test/__main__.py index 24d383bd..3f758bcd 100755 --- a/src/pyromaths/cli/test/__main__.py +++ b/src/pyromaths/cli/test/__main__.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (C) 2016 -- Louis Paternault (spalax@gresille.org) @@ -21,9 +21,11 @@ To display help: -> python -m pyromaths.cli.test --help +> python3 -m pyromaths.cli.test --help """ +from __future__ import unicode_literals +from builtins import input import argparse import gettext import logging @@ -31,7 +33,7 @@ import unittest # Quick and dirty definition of `_` as the identity function -gettext.install('pyromaths', unicode=1) +gettext.install('pyromaths') from pyromaths.cli import exercise_argument, PyromathsException from pyromaths.ex.test import TestPerformer @@ -51,7 +53,7 @@ def ask_confirm(message): """ while True: try: - answer = raw_input("{} (y/n) [n]? ".format(message)) + answer = input("{} (y/n) [n]? ".format(message)) except EOFError: answer = 'n' if answer == 'y': @@ -125,7 +127,7 @@ def argument_parser(): check = subparsers.add_parser( 'check', help=( - "Test exercises (equivalent to `python -m unittest discover`, " + "Test exercises (equivalent to `python3 -m unittest discover`, " "for exercises only)." ), formatter_class=argparse.RawDescriptionHelpFormatter, diff --git a/src/pyromaths/ex/__init__.py b/src/pyromaths/ex/__init__.py index eac00ced..2d608f0a 100644 --- a/src/pyromaths/ex/__init__.py +++ b/src/pyromaths/ex/__init__.py @@ -1,12 +1,14 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # +from __future__ import unicode_literals +from builtins import object import inspect import os import pkgutil import types import sys - +import importlib import jinja2 class Exercise(object): @@ -72,8 +74,8 @@ def __module(filename): def __legacy(function, dirlevel): ''' Create a new class proxying for a legacy exercise 'function'. ''' # Create a proxy class inheriting from LegacyExercise for this function - module = __module(function.func_code.co_filename) - name = function.func_name.title().replace('_', '') + module = __module(function.__code__.co_filename) + name = function.__name__.title().replace('_', '') return type("{}.{}".format(module, name), (LegacyExercise,), dict(description=function.description, @@ -89,7 +91,7 @@ def __hasdescription(obj): if 'description' not in dir(obj): return False description = obj.__dict__['description'] # description must be some kind of string (preferably unicode) - if not isinstance(description, basestring): return False + if not isinstance(description, str): return False return True def __islegacy(obj): @@ -109,7 +111,7 @@ def __level(level): def __import(name=__name__, parent=None): ''' Import 'name' from 'parent' package. ''' - if not isinstance(name, basestring): + if not isinstance(name, str): name = name.__name__ # parent is None: assume 'name' is a package name # hack tout moche pour l'import des exercices dans la version Windows de Pyromaths : @@ -117,15 +119,16 @@ def __import(name=__name__, parent=None): # alors que les exercices cinquiemes.aires ne doivent être appelés qu'ainsi. if "." not in name and hasattr(sys, "frozen"): name = "pyromaths.ex." + name if parent is None: parent = name - elif not isinstance(parent, basestring): + elif not isinstance(parent, str): # assume 'parent' is a package instance parent = parent.__name__ - return __import__(name, fromlist=parent) + return importlib.import_module(name) + # return __import__(name, fromlist=parent) def _exercises(pkg): ''' List exercises in 'pkg' modules. ''' # level defaults to description, then unknown - if 'level' not in dir(pkg): pkg.level = u"Inconnu" + if 'level' not in dir(pkg): pkg.level = "Inconnu" for _, name, ispkg in pkgutil.iter_modules(pkg.__path__, pkg.__name__ + '.'): # skip packages if ispkg: continue; @@ -163,7 +166,7 @@ def load_levels(pkg=None, recursive=True): for ex in _exercises(pkg): for lvl in ex.level: # new level? create its exercise list - if lvl not in levels.keys(): + if lvl not in list(levels.keys()): levels[lvl] = [] levels[lvl].append(ex) diff --git a/src/pyromaths/ex/cinquiemes/__init__.py b/src/pyromaths/ex/cinquiemes/__init__.py index 4232933a..a7d3c4e9 100644 --- a/src/pyromaths/ex/cinquiemes/__init__.py +++ b/src/pyromaths/ex/cinquiemes/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,5 +20,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -description = _(u'5.Cinquième') +from __future__ import unicode_literals +description = _('5.Cinquième') level = description diff --git a/src/pyromaths/ex/cinquiemes/aires.py b/src/pyromaths/ex/cinquiemes/aires.py index b101aa38..3b2f7853 100644 --- a/src/pyromaths/ex/cinquiemes/aires.py +++ b/src/pyromaths/ex/cinquiemes/aires.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import str import random from pyromaths.outils.decimaux import decimaux @@ -80,4 +82,4 @@ def exo_aire_diques(): cor.append("\\end{minipage}\n") return (exo, cor) -exo_aire_diques.description = _(u'Aire de disques') +exo_aire_diques.description = _('Aire de disques') diff --git a/src/pyromaths/ex/cinquiemes/construction.py b/src/pyromaths/ex/cinquiemes/construction.py index 34fa5cb9..51251dd3 100644 --- a/src/pyromaths/ex/cinquiemes/construction.py +++ b/src/pyromaths/ex/cinquiemes/construction.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div from pyromaths.outils import Geometrie as geo import random, math from pyromaths.outils.Affichage import decimaux @@ -79,7 +83,7 @@ def quest_equilateral(exo, cor): angBAC = angABC = 60 exo.append(_(u"\\item Trace un triangle $%s$ équilatéral de côté $\\unit[%s]{cm}$.\\par") % (nom, decimaux(c))) cor.append(_(u"\\item Trace un triangle $%s$ équilatéral de côté $\\unit[%s]{cm}$.\\par") % (nom, decimaux(c))) - x_C = (c * tan(angABC)) / (tan(angABC) + tan(angBAC)) + x_C = old_div((c * tan(angABC)), (tan(angABC) + tan(angBAC))) y_C = x_C * tan(angBAC) cor.append(u"\\begin{pspicture}(-1,-1)(%.3f,%.3f)" % (c + 1, y_C + 1)) cor.append(u"\\pstTriangle(0,0){%s}(%.3f,0){%s}(%.3f,%.3f){%s}" % (A, c, B, x_C, y_C, C)) @@ -136,7 +140,7 @@ def quest_ALA(exo, cor): % (nom, A, B, decimaux(c), B, A, C, angBAC, A, B, C, angABC)) cor.append(_(u"\\item Trace un triangle $%s$ tel que $%s%s=\\unit[%s]{cm}$, $\\widehat{%s%s%s}=%s\\degres$ et $\\widehat{%s%s%s}=%s\\degres$\\par") % (nom, A, B, decimaux(c), B, A, C, angBAC, A, B, C, angABC)) - x_C = (c * tan(angABC)) / (tan(angABC) + tan(angBAC)) + x_C = old_div((c * tan(angABC)), (tan(angABC) + tan(angBAC))) y_C = x_C * tan(angBAC) cor.append(u"\\begin{pspicture}(-0.4,-1)(%.3f,%.3f)" % (c + 1, y_C + 1)) cor.append(u"\\pstTriangle(0,0){%s}(%.3f,0){%s}(%.3f,%.3f){%s}" % (A, c, B, x_C, y_C, C)) @@ -165,7 +169,7 @@ def quest_AAL(exo, cor): % (A, B, C)) cor.append(_(u"Or la somme des trois angles d'un triangle est égale à 180\\degres donc $\\widehat{%s%s%s}=180\\degres-%s\\degres-%s\\degres=%s\\degres$.\\par") % (A, B, C, angBAC, angACB, angABC)) - x_C = (c * tan(angABC)) / (tan(angABC) + tan(angBAC)) + x_C = old_div((c * tan(angABC)), (tan(angABC) + tan(angBAC))) y_C = x_C * tan(angBAC) cor.append(u"\\begin{pspicture}(-1,-1)(%.3f,%.3f)" % (c + 1, y_C + 1)) cor.append(u"\\pstTriangle(0,0){%s}(%.3f,0){%s}(%.3f,%.3f){%s}" % (A, c, B, x_C, y_C, C)) @@ -181,11 +185,11 @@ def quest_isocele_angbase(exo, cor): A, B, C = geo.choix_points(3) nom = shuffle_nom([A, B, C]) angABC = angBAC = random.randint(20, 70) - maxc = max(20, int(35 / tan(angBAC))) # longueur c maximale pour que la hauteur soit 7 cm =0.2*35 - minc = min(20, int(35 / tan(angBAC))) + maxc = max(20, int(old_div(35, tan(angBAC)))) # longueur c maximale pour que la hauteur soit 7 cm =0.2*35 + minc = min(20, int(old_div(35, tan(angBAC)))) c = 0.2 * random.randint(minc, min(maxc, 50)) # longueur AB # Calcul pour tracer - x_C = c / 2 + x_C = old_div(c, 2) y_C = x_C * tan(angBAC) exo.append(_(u"\\item Trace un triangle $%s$ isocèle en $%s$ tel que $%s%s=\\unit[%s]{cm}$, $\\widehat{%s%s%s}=%s\\degres$.") @@ -210,11 +214,11 @@ def quest_isocele_angprincipal(exo, cor): A, B, C = geo.choix_points(3) nom = shuffle_nom([A, B, C]) angACB = 2 * random.randint(20, 60) # ACB est pair entre 40° et 120° - angBAC = angABC = (180 - angACB) / 2 - maxc = max(20, int(35 / tan(angBAC))) # longueur c maximale pour que la hauteur soit 7 cm =0.2*35 + angBAC = angABC = old_div((180 - angACB), 2) + maxc = max(20, int(old_div(35, tan(angBAC)))) # longueur c maximale pour que la hauteur soit 7 cm =0.2*35 c = 0.2 * random.randint(20, min(maxc, 35)) # longueur AB # Calcul pour tracer - x_C = c / 2 + x_C = old_div(c, 2) y_C = x_C * tan(angBAC) exo.append(_(u"\\item Trace un triangle $%s$ isocèle en $%s$ tel que $%s%s=\\unit[%s]{cm}$, $\\widehat{%s%s%s}=%s\\degres$.") @@ -247,7 +251,7 @@ def quest_rectangle_hypo_angle(exo, cor): angABC = 90 - angBAC # angACB=90 # Calcul pour tracer - x_C = (c * tan(angABC)) / (tan(angABC) + tan(angBAC)) + x_C = old_div((c * tan(angABC)), (tan(angABC) + tan(angBAC))) y_C = x_C * tan(angBAC) exo.append(_(u"\\item Trace un triangle $%s$ rectangle en $%s$ tel que $%s%s=\\unit[%s]{cm}$ et $\\widehat{%s%s%s}=%s\\degres$.\\par") @@ -284,8 +288,8 @@ def quest_rectangle_hypo_cote(exo, cor): b = 0.1 * random.randint(int(10 * (c)) + 1, 100) # longueur AC angABC = 90 # calcul pour tracer - angBAC = math.degrees(math.acos(float(c) / float(b))) - x_C = (c * tan(angABC)) / (tan(angABC) + tan(angBAC)) + angBAC = math.degrees(math.acos(old_div(float(c), float(b)))) + x_C = old_div((c * tan(angABC)), (tan(angABC) + tan(angBAC))) y_C = x_C * tan(angBAC) exo.append(_(u"\\item Trace un triangle $%s$ rectangle en $%s$ tel que $%s%s=\\unit[%s]{cm}$, $%s%s=\\unit[%s]{cm}$.\\par") @@ -384,7 +388,7 @@ def quest_rectangle_diag(exo, cor): Diag = 0.1 * random.randint(L + 10, 70) # +1.1 pour éviter les problèmes d'arrondi L = 0.1 * L # Calcul pour tracer - angBAC = math.degrees(math.acos(float(L) / float(Diag))) + angBAC = math.degrees(math.acos(old_div(float(L), float(Diag)))) x_C = L y_C = x_C * tan(angBAC) @@ -460,7 +464,7 @@ def quest_rectangle_angle_diag(exo, cor): angAEB = 2 * random.randint(20, 70) Diag = 0.2 * random.randint(25, 45) # calcul pour tracer - angBAC = (180 - angAEB) / 2 + angBAC = old_div((180 - angAEB), 2) L = Diag * cos(angBAC) x_C = L y_C = x_C * tan(angBAC) @@ -475,7 +479,7 @@ def quest_rectangle_angle_diag(exo, cor): # # cor.append("\columnbreak") cor.append(u"\\begin{pspicture}(-0.4,-1)(%.3f,%.3f)" % (L + 0.4, y_C + 1)) cor.append(u"\\pstTriangle(0,0){%s}(%.3f,0){%s}(%.3f,%.3f){%s}" % (A, L, B, x_C, y_C, C)) - cor.append(u"\\pstGeonode[PosAngle={135,0}](0,%.3f){%s}(%.3f,%.3f){%s}" % (y_C, D, x_C / 2.0, y_C / 2.0, E)) + cor.append(u"\\pstGeonode[PosAngle={135,0}](0,%.3f){%s}(%.3f,%.3f){%s}" % (y_C, D, old_div(x_C, 2.0), old_div(y_C, 2.0), E)) cor.append(u"\\pstLineAB{%s}{%s}" % (C, D)) cor.append(u"\\pstLineAB{%s}{%s}" % (A, D)) cor.append(u"\\pstLineAB[nodesep=-1]{%s}{%s}" % (B, D)) @@ -484,10 +488,10 @@ def quest_rectangle_angle_diag(exo, cor): cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkHashh}" % (E, B)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkHashh}" % (E, C)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkHashh}" % (E, D)) - cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (x_C / 2.0, y_C / 2.0, Diag / 2, angBAC - 7, angBAC + 7)) - cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (x_C / 2.0, y_C / 2.0, Diag / 2, 180 - angBAC - 7, 180 - angBAC + 7)) - cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (x_C / 2.0, y_C / 2.0, Diag / 2, -angBAC - 7, -angBAC + 7)) - cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (x_C / 2.0, y_C / 2.0, Diag / 2, 180 + angBAC - 7, 180 + angBAC + 7)) + cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (old_div(x_C, 2.0), old_div(y_C, 2.0), old_div(Diag, 2), angBAC - 7, angBAC + 7)) + cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (old_div(x_C, 2.0), old_div(y_C, 2.0), old_div(Diag, 2), 180 - angBAC - 7, 180 - angBAC + 7)) + cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (old_div(x_C, 2.0), old_div(y_C, 2.0), old_div(Diag, 2), -angBAC - 7, -angBAC + 7)) + cor.append(u"\\psarc[linecolor=calcul](%.3f,%.3f){%s}{%s}{%s} " % (old_div(x_C, 2.0), old_div(y_C, 2.0), old_div(Diag, 2), 180 + angBAC - 7, 180 + angBAC + 7)) cor.append("\\pcline[linestyle=none](0,0)(%.3f,%.3f)\\aput*{:U}{\\color{enonce}\\unit[%s]{cm}}" % (L, y_C, decimaux(Diag))) cor.append(u"\\color{enonce}\\pstMarkAngle[linecolor=enonce]{%s}{%s}{%s}{%s\\degres}" % (A, E, B, angAEB)) cor.append(u"\\end{pspicture}}{") @@ -497,7 +501,7 @@ def quest_rectangle_angle_diag(exo, cor): cor.append(_(u"\\item je trace la diagonale $(%s%s)$ passant par $%s$ en mesurant \\mbox{$\\widehat{%s%s%s}=%s\\degres$} ;") % (B, D, E, A, E, B, angAEB)) cor.append(_(u"\\item Comme les diagonales du rectangle sont de même longueur, je reporte les longueurs $%s%s=%s%s=\\unit[%s]{cm}$.") - % (E, D, E, B, decimaux(Diag / 2))) + % (E, D, E, B, decimaux(old_div(Diag, 2)))) # # cor.append(_(u"\\item je trace enfin les angles droits en $%s$ et en $%s$ pour palcer le point $%s$.")%(A,C,D)) cor.append("\\end{enumerate}}") # # cor.append("\\end{multicols}") @@ -648,8 +652,8 @@ def quest_parallelogramme_DDA(exo, cor): BD = 0.2 * random.randint(20, 40) # AB mesure entre 4cm et 8cm, tracé horizontalement AC = 0.2 * random.randint(20, 40) # AC mesure entre 4cm et 8cm, tracé horizontalement angAEB = random.randint(35, 145) - AE = AC / 2 - BE = BD / 2 + AE = old_div(AC, 2) + BE = old_div(BD, 2) # calcul pour tracer AB = math.sqrt(AE ** 2 + BE ** 2 - 2 * AE * BE * cos(angAEB)) @@ -665,19 +669,19 @@ def quest_parallelogramme_DDA(exo, cor): cor.append(u"\\begin{enumerate}") cor.append(_(u"\\item Je trace le segment $[%s%s]$ mesurant $\\unit[%s]{cm}$ ;") % (A, C, decimaux(AC))) cor.append(_(u"\\item Dans un parallélogramme les diagonales se coupent en leur milieu donc $%s%s=%s%s=\\unit[%s]{cm}$ et $%s%s=%s%s=\\unit[%s]{cm}$ ;") - % (A, E, C, E, decimaux(AC / 2), B, E, E, D, decimaux(BD / 2))) + % (A, E, C, E, decimaux(old_div(AC, 2)), B, E, E, D, decimaux(old_div(BD, 2)))) cor.append("\\end{enumerate}\n") cor.append(u"\\begin{pspicture}(%.3f,-1)(%.3f,%.3f)" % (min(0, x_D) - 0.4, max(AB, x_C) + 0.4, y_C + 1)) cor.append(u"\\pstGeonode[PosAngle={-135,-45,45,135,%s}](0,0){%s}(%.3f,0){%s}(%.3f,%.3f){%s}(%.3f,%.3f){%s}(%.3f,%.3f){%s}" - % ([round(angBAC - (180 - angAEB) / 2), round(angBAC + (angAEB) / 2)][angAEB > 90], A, AB, B, x_C, y_C, C, x_D, y_D, D, x_C / 2, y_C / 2, E)) + % ([round(angBAC - old_div((180 - angAEB), 2)), round(angBAC + old_div((angAEB), 2))][angAEB > 90], A, AB, B, x_C, y_C, C, x_D, y_D, D, old_div(x_C, 2), old_div(y_C, 2), E)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkHashh}" % (A, E)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkHashh}" % (C, E)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkCros}" % (B, E)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkCros}" % (D, E)) cor.append(u"\\pstLineAB{%s}{%s}\\pstLineAB{%s}{%s}\\pstLineAB{%s}{%s}\\pstLineAB{%s}{%s}" % (A, D, C, D, A, B, B, C)) - cor.append(cotation_h((0, 0), (x_C / 2, y_C / 2), decimaux(AC / 2), couleur="enonce")) - cor.append(cotation_h((x_C / 2, y_C / 2), (AB, 0), decimaux(BD / 2), couleur="enonce")) + cor.append(cotation_h((0, 0), (old_div(x_C, 2), old_div(y_C, 2)), decimaux(old_div(AC, 2)), couleur="enonce")) + cor.append(cotation_h((old_div(x_C, 2), old_div(y_C, 2)), (AB, 0), decimaux(old_div(BD, 2)), couleur="enonce")) cor.append(u"\\color{enonce}\\pstMarkAngle[linecolor=enonce]{%s}{%s}{%s}{%s\\degres}" % (A, E, B, angAEB)) cor.append(u"\\end{pspicture}") @@ -699,9 +703,9 @@ def quest_losange_DD(exo, cor): cor.append(_(u"Je note $%s$ le centre du losange.\\par") % E) cor.append("\\figureadroite{") - cor.append(u"\\begin{pspicture}(%.3f,%.3f)(%.3f,%.3f)" % (-BD / 2 - 0.7, -AC / 2 - 0.4, BD / 2 + 0.4, AC / 2 + 0.4)) + cor.append(u"\\begin{pspicture}(%.3f,%.3f)(%.3f,%.3f)" % (old_div(-BD, 2) - 0.7, old_div(-AC, 2) - 0.4, old_div(BD, 2) + 0.4, old_div(AC, 2) + 0.4)) cor.append(u"\\pstGeonode[PosAngle={-90,0,90,180}](0,%.3f){%s}(%.3f,0){%s}(0,%.3f){%s}(%.3f,0){%s}" - % (-AC / 2, A, BD / 2, B, AC / 2, C, -BD / 2, D)) + % (old_div(-AC, 2), A, old_div(BD, 2), B, old_div(AC, 2), C, old_div(-BD, 2), D)) cor.append("\\pstGeonode[PosAngle=-45](0,0){%s}" % E) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkCross}" % (A, E)) @@ -713,13 +717,13 @@ def quest_losange_DD(exo, cor): cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=enonce}\\MarkHashh}" % (B, C)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=enonce}\\MarkHashh}" % (D, A)) cor.append("\\pstRightAngle[linecolor=calcul]{%s}{%s}{%s}" % (B, E, C)) - cor.append(cotation_h((-BD / 2, 0), (0, 0), decimaux(BD / 2), couleur="enonce")) - cor.append(cotation_h((0, -AC / 2), (0, 0), decimaux(AC / 2), couleur="enonce")) + cor.append(cotation_h((old_div(-BD, 2), 0), (0, 0), decimaux(old_div(BD, 2)), couleur="enonce")) + cor.append(cotation_h((0, old_div(-AC, 2)), (0, 0), decimaux(old_div(AC, 2)), couleur="enonce")) cor.append(u"\\end{pspicture}}{") cor.append(_(u"Les diagonales du losange se coupent perpendiculairement en leur milieu~$%s$ ; on a donc :") % E) cor.append(u"\\begin{enumerate}") cor.append(u"\\item $%s%s=%s%s=\\unit[%s]{cm}$ \\item $%s%s=%s%s=\\unit[%s]{cm}$ ;" - % (A, E, C, E, decimaux(AC / 2), B, E, E, D, decimaux(BD / 2))) + % (A, E, C, E, decimaux(old_div(AC, 2)), B, E, E, D, decimaux(old_div(BD, 2)))) cor.append(u"\\item $(%s%s)\\perp(%s%s)$." % (A, C, B, D)) cor.append("\\end{enumerate}}\n") @@ -747,7 +751,7 @@ def quest_losange_CC(exo, cor): cor.append("\\end{enumerate}\n") cor.append(u"\\begin{pspicture}(%.3f,%.3f)(%.3f,%.3f)" % (min(0, x_D) - 0.4, 0 - 0.4, max(AB, x_C), y_D + 0.4)) cor.append(u"\\pstGeonode[PosAngle={%s,%s,%s,%s}](0,0){%s}(%.3f,0){%s}(%.3f,%.3f){%s}(%.3f,%.3f){%s}" - % (angBAD / 2 - 180, angBAD / 2 - 90, angBAD / 2, angBAD / 2 + 90, A, AB, B, x_C, y_C, C, x_D, y_D, D)) + % (old_div(angBAD, 2) - 180, old_div(angBAD, 2) - 90, old_div(angBAD, 2), old_div(angBAD, 2) + 90, A, AB, B, x_C, y_C, C, x_D, y_D, D)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=enonce}\\MarkHashh}" % (A, B)) cor.append(u"\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=enonce}\\MarkHashh}" % (C, D)) @@ -772,7 +776,7 @@ def quest_losange_CD(exo, cor): AC = 0.1 * random.randint(40, 60) # AB mesure entre 4cm et 7cm, tracé horizontalement angBAC = random.randint(25, 75) # Calcul pour tracer - x_D = AC / 2 + x_D = old_div(AC, 2) y_D = AC / 2 * tan(angBAC) exo.append(_(u"\\item Trace un losange $%s$ tel que $%s%s=\\unit[%s]{cm}$ et $\\widehat{%s%s%s}=%s\\degres$.\\par") @@ -811,8 +815,8 @@ def quest_losange_CDbis(exo, cor): AC = 0.1 * random.randint(40, 60) # AB mesure entre 4cm et 7cm, tracé horizontalement angCDA = 2 * random.randint(15, 70) # Calcul pour tracer - angCAD = (180 - angCDA) / 2 - x_D = AC / 2 + angCAD = old_div((180 - angCDA), 2) + x_D = old_div(AC, 2) y_D = AC / 2 * tan(angCAD) exo.append(_(u"\\item Trace un losange $%s$ tel que $%s%s=\\unit[%s]{cm}$ et $\\widehat{%s%s%s}=%s\\degres$.\\par") @@ -873,12 +877,12 @@ def carre_diag(exo, cor): cor.append("\\begin{enumerate}") cor.append(u"\\item $(%s%s)\\perp(%s%s)$." % (A, C, B, D)) cor.append(u"\\item $%s%s=%s%s=%s%s=%s%s=\\unit[%s]{cm}$ ;" - % (A, E, C, E, B, E, D, E, decimaux(BD / 2))) + % (A, E, C, E, B, E, D, E, decimaux(old_div(BD, 2)))) cor.append("\\end{enumerate}\n") - cor.append("\\begin{pspicture}(%.3f,%.3f)(%.3f,%.3f)" % (-BD / 2 - 0.4, -AC / 2 - 0.4, BD / 2 + 0.4, AC / 2 + 0.4)) + cor.append("\\begin{pspicture}(%.3f,%.3f)(%.3f,%.3f)" % (old_div(-BD, 2) - 0.4, old_div(-AC, 2) - 0.4, old_div(BD, 2) + 0.4, old_div(AC, 2) + 0.4)) cor.append("\\pstGeonode[PosAngle={-90,0,90,180}](0,%.3f){%s}(%.3f,0){%s}(0,%.3f){%s}(%.3f,0){%s}" - % (-AC / 2, A, BD / 2, B, AC / 2, C, -BD / 2, D)) + % (old_div(-AC, 2), A, old_div(BD, 2), B, old_div(AC, 2), C, old_div(-BD, 2), D)) cor.append("\\pstGeonode[PosAngle=-45](0,0){%s}" % E) cor.append("\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=calcul}\\MarkCros}" % (A, E)) @@ -890,5 +894,5 @@ def carre_diag(exo, cor): cor.append("\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=enonce}\\MarkHashh}" % (B, C)) cor.append("\\pstLineAB{%s}{%s}\\lput{:U}{\\psset{linecolor=enonce}\\MarkHashh}" % (D, A)) cor.append("\\pstRightAngle[linecolor=calcul]{%s}{%s}{%s}" % (B, E, C)) - cor.append(cotation_h((-BD / 2, 0), (0, 0), decimaux(BD / 2), couleur="enonce")) + cor.append(cotation_h((old_div(-BD, 2), 0), (0, 0), decimaux(old_div(BD, 2)), couleur="enonce")) cor.append(u"\\end{pspicture}") diff --git a/src/pyromaths/ex/cinquiemes/fractions.py b/src/pyromaths/ex/cinquiemes/fractions.py index 35ec273a..2f8fe854 100644 --- a/src/pyromaths/ex/cinquiemes/fractions.py +++ b/src/pyromaths/ex/cinquiemes/fractions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -22,6 +22,10 @@ # # from pyromaths.classes.Fractions import Fraction # Fractions de pyromaths +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div import random from pyromaths.outils import Arithmetique from pyromaths.outils.Priorites3 import texify, priorites @@ -76,7 +80,7 @@ def valeurs_somme(): for dummy in range(2): op = "+-"[random.randrange(2)] n2, d2 = random.randrange(1, 11), random.randrange(2, 11) - if op == "-" and 1 - n2 / d2 > 0: + if op == "-" and 1 - old_div(n2, d2) > 0: l.append(_('1 %s Fraction(%s, %s)') % (op, n2, d2)) else: l.append(_('Fraction(%s, %s) %s 1') % (n2, d2, op)) @@ -85,7 +89,7 @@ def valeurs_somme(): op = "+-"[random.randrange(2)] n1 = random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) - if op == "-" and n1 - n2 / d2 > 0: + if op == "-" and n1 - old_div(n2, d2) > 0: l.append(_('%s %s Fraction(%s, %s)') % (n1, op, n2, d2)) else: l.append(_('Fraction(%s, %s) %s %s') % (n2, d2, op, n1)) @@ -102,7 +106,7 @@ def valeurs_somme(): op = "+-"[random.randrange(2)] n1, d1 = random.randrange(1, 11), random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) * d1 - if op == "-" and n1 / d1 - n2 / d2 > 0: + if op == "-" and old_div(n1, d1) - old_div(n2, d2) > 0: l.append(_('Fraction(%s, %s) %s Fraction(%s, %s)') % (n1, d1, op, n2, d2)) else: l.append(_('Fraction(%s, %s) %s Fraction(%s, %s)') % (n2, d2, op, n1, d1)) diff --git a/src/pyromaths/ex/cinquiemes/priorites.py b/src/pyromaths/ex/cinquiemes/priorites.py index e068e791..01ee6667 100644 --- a/src/pyromaths/ex/cinquiemes/priorites.py +++ b/src/pyromaths/ex/cinquiemes/priorites.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -22,6 +22,11 @@ # # from pyromaths.outils import ecrit_tex, valeur_alea, signe, pgcd, ppcm +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import random def valeurs(nb, entier=1): # renvoie les 2 listes contenant les opérateurs et les opérandes. @@ -92,7 +97,7 @@ def valeurs(nb, entier=1): # renvoie les 2 listes contenant les opérateurs et if entier: loperandes = [random.randrange(12) + 2 for i in range(nb)] else: - loperandes = [((random.randrange(88) + 12) * 1.0) / 10 for i in + loperandes = [old_div(((random.randrange(88) + 12) * 1.0), 10) for i in range(nb)] return (loperateurs, loperandes) @@ -220,7 +225,7 @@ def calcul(a, op, b, entier=1): # retourne 'hp' (hors programme) ou le résulta elif not entier and (a * 1000) % (b * 100): return 'hp' else: - return a / b + return old_div(a, b) def priorites(): diff --git a/src/pyromaths/ex/cinquiemes/proportionnalite.py b/src/pyromaths/ex/cinquiemes/proportionnalite.py index c205631e..7b1b8012 100644 --- a/src/pyromaths/ex/cinquiemes/proportionnalite.py +++ b/src/pyromaths/ex/cinquiemes/proportionnalite.py @@ -19,6 +19,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div from random import randint, randrange from pyromaths.outils.decimaux import decimaux @@ -64,7 +68,7 @@ def exo_echelles(): enonce = reponses.pop(choix) # sur la deuxième ligne du tableau, on écrit en cm, en gras, les nombres calculés - tab_reels = [ "\\bf"*(i != choix) + decimaux(reels[i] / 10.0) for i in range(4)] + tab_reels = [ "\\bf"*(i != choix) + decimaux(old_div(reels[i], 10.0)) for i in range(4)] # Pour placer les quatre lettres sur le plan cotation_couleur = [["a", ""], @@ -100,18 +104,18 @@ def exo_echelles(): "\\end{pspicture}"] - exo = [_(u"\\exercice Sur ce plan, la longueur $%s$ mesure en réalité \\unit[%s]{m} :\n") % (enonce, decimaux(reels[choix] / 1000.0))] \ + exo = [_(u"\\exercice Sur ce plan, la longueur $%s$ mesure en réalité \\unit[%s]{m} :\n") % (enonce, decimaux(old_div(reels[choix], 1000.0)))] \ + figure + \ ["\\begin{enumerate}", _(u"\\item Déterminer l'échelle de ce plan."), _(u"\\item Déterminer les longueurs réelles $%s$, $%s$ et $%s$.") % (reponses[0], reponses[1], reponses[2]), "\\end{enumerate}"] - cor = [_(u"\\exercice* Sur ce plan, la longueur $%s$ mesure en réalité \\unit[%s]{m} : \n") % (enonce, decimaux(reels[choix] / 1000.0))] \ + cor = [_(u"\\exercice* Sur ce plan, la longueur $%s$ mesure en réalité \\unit[%s]{m} : \n") % (enonce, decimaux(old_div(reels[choix], 1000.0)))] \ + figure + \ ["\\begin{enumerate}", _(u"\\item Déterminer l'échelle de ce plan.\\par"), - _(u"Sur le plan, je mesure que $%s=\\unit[%s]{cm}$.\\par") % (enonce, decimaux(plan[choix] / 10.0)), - _(u"Or on sait que en réalité $%s = \\unit[%s]{m} = \\unit[%s]{cm}$") % (enonce, decimaux(reels[choix] / 1000.0), decimaux(reels[choix] / 10.0)), + _(u"Sur le plan, je mesure que $%s=\\unit[%s]{cm}$.\\par") % (enonce, decimaux(old_div(plan[choix], 10.0))), + _(u"Or on sait que en réalité $%s = \\unit[%s]{m} = \\unit[%s]{cm}$") % (enonce, decimaux(old_div(reels[choix], 1000.0)), decimaux(old_div(reels[choix], 10.0))), _(u" et $%s \\div %s = %s$.\\par") % (decimaux(reels[choix]), decimaux(plan[choix]), decimaux(echelle)), _(u"L'échelle de ce plan est donc $1/%s^e$.") % echelle, _(u"\\item Déterminer les longueurs réelles $%s$, $%s$ et $%s$.\n") % (reponses[0], reponses[1], reponses[2]), @@ -119,7 +123,7 @@ def exo_echelles(): "\\begin{tabular}{|l|c|c|c|c|c}", ("\\multicolumn{1}{c}{}" + "&\\multicolumn{1}{c}{$%s$}"*4 + "\\\\") % ("a", "b", "c", "d"), "\\cline{1-5}", - _("Sur le plan (en cm) & %s & %s & %s & %s &\\rnode{plan1}{}\\\\") % tuple(map(lambda n:decimaux(n / 10.0), plan)), + _("Sur le plan (en cm) & %s & %s & %s & %s &\\rnode{plan1}{}\\\\") % tuple([decimaux(old_div(n, 10.0)) for n in plan]), "\\cline{1-5}", _(u"En réalité (en cm) & %s & %s & %s & %s &\\rnode{plan2}{}\\\\") % tuple(tab_reels), "\\cline{1-5}", @@ -127,7 +131,7 @@ def exo_echelles(): "\\ncbar{->}{plan1}{plan2}\\Aput{$\\times %s$}" % echelle, _(u"Pour conclure, on convertit ses longueurs en m :\\par"), "$$a = \\unit[%s]{m} \\quad ; \\quad b = \\unit[%s]{m} \\quad ; \\quad c = \\unit[%s]{m} \\quad ; \\quad d =\\unit[%s]{m}$$"\ - % tuple(map(lambda n:decimaux(n / 1000.0), reels)), + % tuple([decimaux(old_div(n, 1000.0)) for n in reels]), "\\end{enumerate}"] return exo, cor @@ -138,10 +142,10 @@ def exo_echelles(): def exo_fruits(): fruit = [_("Cerises"), _("Tomates"), _("Pommes"), _("Poires"), _("Raisin"), _("Oranges")][randrange(6)] while 1: - a, b, c = randint(10, 50) / 10.0, randint(10, 50) / 10.0, randint(10, 50) / 10.0 + a, b, c = old_div(randint(10, 50), 10.0), old_div(randint(10, 50), 10.0), old_div(randint(10, 50), 10.0) if a != b and a != c and b != c: break - tarif = randint(20, 50) / 10.0 + tarif = old_div(randint(20, 50), 10.0) fruits_c = (fruit, a, b, c) fruits_e = (fruit, decimaux(a), decimaux(b), "") prix_c = (_("prix"), decimaux(fruits_c[1] * tarif), decimaux(fruits_c[2] * tarif), decimaux(fruits_c[3] * tarif)) diff --git a/src/pyromaths/ex/cinquiemes/relatifs.py b/src/pyromaths/ex/cinquiemes/relatifs.py index b3c47f5c..db68c7f1 100644 --- a/src/pyromaths/ex/cinquiemes/relatifs.py +++ b/src/pyromaths/ex/cinquiemes/relatifs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -24,6 +24,10 @@ # Pyromaths : Poser des opérations #---------------------------------------------------------------------- +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div from pyromaths.outils import Arithmetique from pyromaths.outils.Affichage import TeX, tex_coef import random @@ -60,12 +64,12 @@ def moins(pyromax): return (a + b, a) def plus_dec(pyromax): - (a, b) = (Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax) / 10.0, Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax) / 10.0) + (a, b) = (old_div(Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax), 10.0), old_div(Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax), 10.0)) return (a, b) def moins_dec(pyromax): - (a, b) = (Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax) / 10.0, Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax) / 10.0) + (a, b) = (old_div(Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax), 10.0), old_div(Arithmetique.valeur_alea(-10 * pyromax, 10 * pyromax), 10.0)) return (a + b, a) diff --git a/src/pyromaths/ex/cinquiemes/reperage.py b/src/pyromaths/ex/cinquiemes/reperage.py index 4640ffbd..9f1c4b87 100644 --- a/src/pyromaths/ex/cinquiemes/reperage.py +++ b/src/pyromaths/ex/cinquiemes/reperage.py @@ -1,3 +1,5 @@ +from __future__ import division +from __future__ import unicode_literals # Pyromaths # -*- coding: utf-8 -*- # @@ -20,6 +22,10 @@ # along with this program; if notPopen, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +from builtins import chr +from builtins import str +from builtins import range +from past.utils import old_div import random from pyromaths.outils.Affichage import decimaux @@ -96,31 +102,31 @@ def coordo_pts(nb): if j == 600: # Correction d'un bug l, i, j = [], 0, 0 - a = float(random.randrange(-9, 10)) / 2 - b = float(random.randrange(-9, 10)) / 2 + a = old_div(float(random.randrange(-9, 10)), 2) + b = old_div(float(random.randrange(-9, 10)), 2) if ((a, b) not in l) and valide((a, b), l)and quadrant((a, b), l): l.append((a, b)) i = i + 1 if nb >= 4: - a = float(random.randrange(-9, 10)) / 2 + a = old_div(float(random.randrange(-9, 10)), 2) while not valide((0, a), l): - a = float(random.randrange(-9, 10)) / 2 + a = old_div(float(random.randrange(-9, 10)), 2) rg = random.randrange(0, len(l) - 1) l[rg:rg] = [(0, a)] i = i + 1 if nb >= 5: - b = float(random.randrange(-9, 10)) / 2 + b = old_div(float(random.randrange(-9, 10)), 2) while not valide((b, 0), l): - b = float(random.randrange(-9, 10)) / 2 + b = old_div(float(random.randrange(-9, 10)), 2) rg = random.randrange(0, len(l) - 1) l[rg:rg] = [(b, 0)] i = i + 1 while i >= 6 and i < nb and i < 10: - a = float(random.randrange(-9, 10)) / 2 - b = float(random.randrange(-9, 10)) / 2 + a = old_div(float(random.randrange(-9, 10)), 2) + b = old_div(float(random.randrange(-9, 10)), 2) j = j + 1 if j == 600: break @@ -128,23 +134,23 @@ def coordo_pts(nb): l.append((a, b)) i = i + 1 if nb >= 11 and len(l) == 10: - a = float(random.randrange(-9, 10)) / 2 + a = old_div(float(random.randrange(-9, 10)), 2) while not valide((0, a), l): - a = float(random.randrange(-9, 10)) / 2 + a = old_div(float(random.randrange(-9, 10)), 2) rg = random.randrange(6, len(l) - 1) l[rg:rg] = [(0, a)] i = i + 1 if nb >= 11 and len(l) == 11: - b = float(random.randrange(-9, 10)) / 2 + b = old_div(float(random.randrange(-9, 10)), 2) while not valide((b, 0), l): - b = float(random.randrange(-9, 10)) / 2 + b = old_div(float(random.randrange(-9, 10)), 2) rg = random.randrange(6, len(l) - 1) l[rg:rg] = [(b, 0)] i = i + 1 while i >= 12 and i < nb : - a = float(random.randrange(-9, 10)) / 2 - b = float(random.randrange(-9, 10)) / 2 + a = old_div(float(random.randrange(-9, 10)), 2) + b = old_div(float(random.randrange(-9, 10)), 2) k = k + 1 if k == 600: break diff --git a/src/pyromaths/ex/cinquiemes/statistiques.py b/src/pyromaths/ex/cinquiemes/statistiques.py index 6019cd69..e2893576 100644 --- a/src/pyromaths/ex/cinquiemes/statistiques.py +++ b/src/pyromaths/ex/cinquiemes/statistiques.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import random from math import cos, sin, radians from pyromaths.outils.decimaux import decimaux @@ -101,7 +106,7 @@ def diagramme_tex(typed=2, val=[[], []], aide=0): diag += u"\\psaxes[Dx=1,dx=1,Dy=10,dy=1]{->}(0,0)(" + str(grad) + ",11)\n" for f in range(len(val[1])): - diag += u"\\psline[linewidth=0.1,linecolor=green](" + val[0][f + 1] + ",0)(" + val[0][f + 1] + "," + str(val[1][f] / 10.0) + ")\n" + diag += u"\\psline[linewidth=0.1,linecolor=green](" + val[0][f + 1] + ",0)(" + val[0][f + 1] + "," + str(old_div(val[1][f], 10.0)) + ")\n" diag += u"\\rput(0,11.2){\\small Fréquences (\\%)}\n" diag += u"\\rput(" + str(grad + 0.5) + ",0){\\small " + val[0][0] + "}\n" @@ -119,12 +124,12 @@ def diagramme_tex(typed=2, val=[[], []], aide=0): for v in range(len(val[1]) - 1): diag += u"\\pswedge[fillstyle=solid,fillcolor=" + couleur[v % 12] + "](0,0){3}{" + str(debut) + "}{" + str(fin) + "}\n" - diag_texte += u"\\rput[r]{" + str((debut + fin) / 2.0) + "}(" + str(3 * round(cos(radians((debut + fin) / 2.0)), 2)) + "," + str(3 * round(sin(radians((debut + fin) / 2.0)), 2)) + "){\\small \\bfseries{" + val[0][v + 1] + "}}\n" + diag_texte += u"\\rput[r]{" + str(old_div((debut + fin), 2.0)) + "}(" + str(3 * round(cos(radians(old_div((debut + fin), 2.0))), 2)) + "," + str(3 * round(sin(radians(old_div((debut + fin), 2.0))), 2)) + "){\\small \\bfseries{" + val[0][v + 1] + "}}\n" debut = fin fin += round(val[1][v + 1] * 3.6, 0) liste_fin.append(fin) diag += u"\\pswedge[fillstyle=solid,fillcolor=" + couleur[(len(val[1]) - 1) % 12] + "](0,0){3}{" + str(debut) + "}{360}\n" - diag_texte += u"\\rput[r]{" + str((debut + fin) / 2.0) + "}(" + str(3 * round(cos(radians((debut + fin) / 2.0)), 2)) + "," + str(3 * round(sin(radians((debut + fin) / 2.0)), 2)) + "){\\small \\bfseries{" + val[0][-1] + "}}\n" + diag_texte += u"\\rput[r]{" + str(old_div((debut + fin), 2.0)) + "}(" + str(3 * round(cos(radians(old_div((debut + fin), 2.0))), 2)) + "," + str(3 * round(sin(radians(old_div((debut + fin), 2.0))), 2)) + "){\\small \\bfseries{" + val[0][-1] + "}}\n" if aide != 0: temp = [int(3.6 * v) for v in val[1]] @@ -152,12 +157,12 @@ def diagramme_tex(typed=2, val=[[], []], aide=0): for v in range(len(val[1]) - 1): diag += u"\\pswedge[fillstyle=solid,fillcolor=" + couleur[v % 12] + "](0,0){3}{" + str(debut) + "}{" + str(fin) + "}\n" - diag_texte += u"\\rput[r]{" + str((debut + fin) / 2.0) + "}(" + str(3 * round(cos(radians((debut + fin) / 2.0)), 2)) + "," + str(3 * round(sin(radians((debut + fin) / 2.0)), 2)) + "){\\small \\bfseries{" + val[0][v + 1] + "}}\n" # FIX problème hauteur textes superposés + diag_texte += u"\\rput[r]{" + str(old_div((debut + fin), 2.0)) + "}(" + str(3 * round(cos(radians(old_div((debut + fin), 2.0))), 2)) + "," + str(3 * round(sin(radians(old_div((debut + fin), 2.0))), 2)) + "){\\small \\bfseries{" + val[0][v + 1] + "}}\n" # FIX problème hauteur textes superposés debut = fin fin += round(val[1][v + 1] * 1.8, 0) liste_fin.append(fin) diag += u"\\pswedge[fillstyle=solid,fillcolor=" + couleur[(len(val[1]) - 1) % 12] + "](0,0){3}{" + str(debut) + "}{180}\n" - diag_texte += u"\\rput[r]{" + str((debut + fin) / 2.0) + "}(" + str(3 * round(cos(radians((debut + fin) / 2.0)), 2)) + "," + str(3 * round(sin(radians((debut + fin) / 2.0)), 2)) + "){\\small \\bfseries{" + val[0][-1] + "}}\n" + diag_texte += u"\\rput[r]{" + str(old_div((debut + fin), 2.0)) + "}(" + str(3 * round(cos(radians(old_div((debut + fin), 2.0))), 2)) + "," + str(3 * round(sin(radians(old_div((debut + fin), 2.0))), 2)) + "){\\small \\bfseries{" + val[0][-1] + "}}\n" if aide != 0: temp = [int(1.8 * v) for v in val[1]] @@ -199,7 +204,7 @@ def tableau_diagramme_tex(typed=2, val=[[], []], larg="c"): tab = texte + tab tab += _(u"Hauteur (cm)") for frequence in val[1]: - tab += " & " + decimaux(round(frequence / 10.0, 1)) + tab += " & " + decimaux(round(old_div(frequence, 10.0), 1)) tab += " & 10 \\\\\\hline\n" elif typed == 2: # Diagramme circulaire @@ -291,7 +296,7 @@ def exo_notes(): classes += [[val, val + len_classe]] val = val + len_classe - titres = [_(u"Classes de notes")] + [u"$" + str(f[0]) + u" \leq n < " + str(f[1]) + u"$" for f in classes[:-1]] + [u"$" + str(classes[-1][0]) + u" \leq n \leq 20$"] + titres = [_(u"Classes de notes")] + [u"$" + str(f[0]) + u" \leqslant n < " + str(f[1]) + u"$" for f in classes[:-1]] + [u"$" + str(classes[-1][0]) + u" \leqslant n \leqslant 20$"] exo.append(_(u"Voici un tableau regroupant les notes d'une classe lors d'un contrôle :\\par")) cor.append(_(u"Voici un tableau regroupant les notes d'une classe lors d'un contrôle :\\par")) @@ -483,17 +488,17 @@ def exo_ages(): titres = [ _(u"Classes d'âges"), - _(u"$0 \\leq n \\leq 20$"), - _(u"$20 \\leq n \\leq 40$"), - _(u"$40 \\leq n \\leq 60$"), - _(u"$60 \\leq n \\leq 80$"), - _(u"$80 \\geq n$"), + _(u"$0 \\leqslant n \\leqslant 20$"), + _(u"$20 \\leqslant n \\leqslant 40$"), + _(u"$40 \\leqslant n \\leqslant 60$"), + _(u"$60 \\leqslant n \\leqslant 80$"), + _(u"$80 \\geqslant n$"), ] liste_pgcd = [pgcd(frequences[i], frequences[i + 1]) for i in range(len(frequences) - 2)] liste_pgcd.sort() pourcent = liste_pgcd[0] - parts = 100 / pourcent + parts = old_div(100, pourcent) effectifs = [f * population / 100 for f in frequences] cor.append(_(u"Le diagramme ") + diagramme_texte + _(u" est partagé en ") + str(parts) + _(u" parts symbolisées par des lignes grises en pointillés.\\par")) @@ -550,16 +555,16 @@ def exo_vote(): exo.append(_(u"Sachant qu'il y a 25 élèves dans la classe, compléter alors le tableau ci-dessus.\\par")) cor.append(_(u"Sachant qu'il y a 25 élèves dans la classe, compléter alors le tableau ci-dessus.\\par")) - effectifs[idx] = freq1 / 4 + effectifs[idx] = old_div(freq1, 4) idx2 = effectifs.index(-1) - effectifs[idx2] = 25 - eff1 - eff2 - freq1 / 4 + effectifs[idx2] = 25 - eff1 - eff2 - old_div(freq1, 4) frequences = [ 4 * f for f in effectifs ] cor.append("\\par") cor.append(_(u"Comme il y a 25 élèves dans la classe, ce qui représente 100 \\% des votes, il faut diviser la fréquence connue pour trouver l'effectif d'élèves ayant voté pour ") + titres[idx + 1] + _(" et on trouve : ")) - cor.append(u"$\\dfrac{" + str(freq1) + "}{4}=" + str(freq1 / 4) + _(u"$ élève(s) pour ") + titres[idx + 1] + ".\\par") + cor.append(u"$\\dfrac{" + str(freq1) + "}{4}=" + str(old_div(freq1, 4)) + _(u"$ élève(s) pour ") + titres[idx + 1] + ".\\par") cor.append(_(u"Ensuite, pour trouver l'effectif d'élèves ayant voté pour ") + titres[idx2 + 1] + _(u", il suffit de soustraire à 25 les effectifs connus :\\par")) - cor.append(u"$25 - " + str(eff1) + " - " + str(eff2) + " - " + str(freq1 / 4) + " = " + str(effectifs[idx2]) + _(u"$ élève(s) pour ") + titres[idx2 + 1] + ".\\par") + cor.append(u"$25 - " + str(eff1) + " - " + str(eff2) + " - " + str(old_div(freq1, 4)) + " = " + str(effectifs[idx2]) + _(u"$ élève(s) pour ") + titres[idx2 + 1] + ".\\par") cor.append(_(u"Enfin, pour le calcul des fréquences manquantes, il faut multiplier chaque effectif par 4, ce qui fourni le tableau ci-dessous.\\par")) cor.append(tableau_tex(titres, ">{\\centering}p{2.1cm}", 1, 1, [effectifs, frequences])) diff --git a/src/pyromaths/ex/cinquiemes/symetrie.py b/src/pyromaths/ex/cinquiemes/symetrie.py index 5ef65587..dfff04a6 100644 --- a/src/pyromaths/ex/cinquiemes/symetrie.py +++ b/src/pyromaths/ex/cinquiemes/symetrie.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import chr +from builtins import range +from past.utils import old_div import random from math import atan, cos, pi, sin @@ -32,26 +37,26 @@ def valeurs_quad2(nb_pts): vals = [] for i in range(nb_pts): - angle = random.randrange((i * 360) / nb_pts, ((i + 1) * 360) / - nb_pts) - vals.append(((random.randrange(1, 7) * .5) * cos((angle * pi) / - 180), (random.randrange(1, 7) * .5) * sin((angle * - pi) / 180))) + angle = random.randrange(old_div((i * 360), nb_pts), old_div(((i + 1) * 360), + nb_pts)) + vals.append(((random.randrange(1, 7) * .5) * cos(old_div((angle * pi), + 180)), (random.randrange(1, 7) * .5) * sin(old_div((angle * + pi), 180)))) return vals def valeurs_quad(nb_pts): vals = [] for i in range(nb_pts): - (alpha, beta) = ((i * 360) / nb_pts, ((i + 1) * 360) / nb_pts) + (alpha, beta) = (old_div((i * 360), nb_pts), old_div(((i + 1) * 360), nb_pts)) (x, y, angle) = (0, 0, 0) while x == 0 or angle < alpha or angle > beta: (x, y) = (random.randrange(-6, 7) * .5, random.randrange(-6, 7) * .5) if x > 0: - angle = int((atan((y * 1.0) / x) * 180) / pi + 360) % 360 + angle = int(old_div((atan(old_div((y * 1.0), x)) * 180), pi) + 360) % 360 if x < 0: - angle = int((atan((y * 1.0) / x) * 180) / pi + 180) + angle = int(old_div((atan(old_div((y * 1.0), x)) * 180), pi) + 180) vals.append((x, y)) return vals diff --git a/src/pyromaths/ex/examples/__init__.py b/src/pyromaths/ex/examples/__init__.py index ca171f07..a9a5e52a 100644 --- a/src/pyromaths/ex/examples/__init__.py +++ b/src/pyromaths/ex/examples/__init__.py @@ -1 +1,2 @@ -level = u'Exemples' +from __future__ import unicode_literals +level = 'Exemples' diff --git a/src/pyromaths/ex/examples/helloworld.py b/src/pyromaths/ex/examples/helloworld.py index 2f044dfa..824364c8 100644 --- a/src/pyromaths/ex/examples/helloworld.py +++ b/src/pyromaths/ex/examples/helloworld.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from __future__ import unicode_literals from pyromaths import ex class HelloWorld(ex.TexExercise): diff --git a/src/pyromaths/ex/examples/random.py b/src/pyromaths/ex/examples/random.py index ef40e8b1..681a7298 100644 --- a/src/pyromaths/ex/examples/random.py +++ b/src/pyromaths/ex/examples/random.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import +from __future__ import unicode_literals +# -*- coding: utf-8 -*- import random import textwrap diff --git a/src/pyromaths/ex/lycee/CercleTrigo.py b/src/pyromaths/ex/lycee/CercleTrigo.py index 9003ca75..a359c6a4 100644 --- a/src/pyromaths/ex/lycee/CercleTrigo.py +++ b/src/pyromaths/ex/lycee/CercleTrigo.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import random from math import cos, sin, radians, pi from pyromaths.outils.decimaux import decimaux @@ -32,12 +37,12 @@ def deg2rad(n): """Effectue la conversion de degrés entre 0 et 360° vers radians.""" p = pgcd(n,180) - return [n/p,180/p] + return [old_div(n,p),old_div(180,p)] 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] + return [old_div(f,p) for f in liste] def rad2deg(liste): """Effectue la conversion de radians entre 0 et 2pi vers degrés. Le paramètre est une liste d'entiers, pour représenter une fraction.""" @@ -87,10 +92,10 @@ def cercle_trigo(code=0,*args): idx = 0 if not code: for a in range(11): - if (a+1)/6.0 not in [0.5,1,1.5]: + if old_div((a+1),6.0) not in [0.5,1,1.5]: figure += "\\psline[linecolor=LightSkyBlue,linestyle=dashed](0,0)("+str(round(cos((a+1)*pi/6),2))+","+str(round(sin((a+1)*pi/6),2))+")\n" for a in range(9): - if (a+1)/5.0 not in [0.5,1,1.5]: + if old_div((a+1),5.0) not in [0.5,1,1.5]: figure += "\\psline[linecolor=LightSlateGray,linestyle=dashed](0,0)("+str(round(cos((a+1)*pi/5),2))+","+str(round(sin((a+1)*pi/5),2))+")\n" for a in range(4): figure += "\\psline[linecolor=LightGreen,linestyle=dashed](0,0)("+str(round(cos((2*a+1)*pi/4),2))+","+str(round(sin((2*a+1)*pi/4),2))+")\n" @@ -108,7 +113,7 @@ def cercle_trigo(code=0,*args): else: figure += "\\rput("+str(round(1.25*cos(f),2))+","+str(round(1.25*sin(f),2))+"){$M_"+str(idx)+"$}\n" idx += 1 - figure += """\\uput[dl](0,0){$O$} + figure += r"""\uput[dl](0,0){$O$} \uput[dr](1,0){$I$} \uput[ul](0,1){$J$}""" figure += "\n\\end{pspicture}" @@ -233,7 +238,7 @@ def cercle_trigonometrique(): cor.append(_(u"\\item Déterminer les mesures principales des angles suivants en radians : %s, %s, %s, %s et %s~rad.\\par") %(tuple(mes_rad_tex[5:10]))) rep = mes_princ(radq3[0]) - nb_tours = (radq3[0][0]-rep[0])/(2*radq3[0][1]) + nb_tours = old_div((radq3[0][0]-rep[0]),(2*radq3[0][1])) cor.append(_(u"Une mesure d'angle en radians est définie modulo $2\\pi$, c'est-à-dire que l'ajout ou la suppression d'un tour ( qui vaut $2\\pi$ ou 360\\degres ) ne change pas un angle.\\par")) cor.append(_(u"Concrètement, avec le premier angle de la question, on remarque que :\\par")) diff --git a/src/pyromaths/ex/lycee/Derivation.py b/src/pyromaths/ex/lycee/Derivation.py index 0adf0eb2..29371259 100644 --- a/src/pyromaths/ex/lycee/Derivation.py +++ b/src/pyromaths/ex/lycee/Derivation.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import str +from builtins import range from itertools import count ''' Created on 24 janv. 2015 @@ -30,7 +33,6 @@ from pyromaths.outils.Arithmetique import pgcd from pyromaths.classes.Fractions import Fraction from random import randrange, shuffle -from string import zfill def InitPoints(minimum=-6.1, maximum=6.1, nbval=3): dY = [] @@ -129,9 +131,9 @@ def tex_statement(self): exo.append(r'import interpolate;') exo.append(r'import geometry;') exo.append(r'defaultpen(fontsize(9pt));') - exo.append(r'real[] xpt={%s};' % (",".join([zfill(str(a), 2) for a in self.lX1]))) - exo.append(r'real[] ypt={%s};' % (",".join([zfill(str(a), 2) for a in self.lY1]))) - exo.append(r'real[] dy= {%s};' % (",".join([zfill(str(a), 2) for a in dY1]))) + exo.append(r'real[] xpt={%s};' % (",".join([str(a).zfill(2) for a in self.lX1]))) + exo.append(r'real[] ypt={%s};' % (",".join([str(a).zfill(2) for a in self.lY1]))) + exo.append(r'real[] dy= {%s};' % (",".join([str(a).zfill(2) for a in dY1]))) exo.append(r'real f(real t){return pwhermite(xpt,ypt,dy)(t);}') exo.append(r'path Cf=graph(f,-6.1,6.1);') exo.append(r'void tangente(int k,real lg=sqrt(1+dy[k]^2),real ld=lg, pen p=black+1, arrowbar arr=Arrows(SimpleHead,size=9pt)) {') @@ -180,9 +182,9 @@ def tex_answer(self): exo.append(r'import interpolate;') exo.append(r'import geometry;') exo.append(r'defaultpen(fontsize(9pt));') - exo.append(r'real[] xpt={%s};' % (",".join([zfill(str(a), 2) for a in self.lX2]))) - exo.append(r'real[] ypt={%s};' % (",".join([zfill(str(a), 2) for a in self.lY2]))) - exo.append(r'real[] dy= {%s};' % (",".join([zfill(str(a), 2) for a in dY2]))) + exo.append(r'real[] xpt={%s};' % (",".join([str(a).zfill(2) for a in self.lX2]))) + exo.append(r'real[] ypt={%s};' % (",".join([str(a).zfill( 2) for a in self.lY2]))) + exo.append(r'real[] dy= {%s};' % (",".join([str(a).zfill(2) for a in dY2]))) exo.append(r'real f(real t){return pwhermite(xpt,ypt,dy)(t);}') exo.append(r'path Cf=graph(f,-6.1,6.1);') exo.append(r'void tangente(int k,real lg=sqrt(1+dy[k]^2),real ld=lg, pen p=black+1, arrowbar arr=Arrows(SimpleHead,size=9pt)) {') diff --git a/src/pyromaths/ex/lycee/ExoPolynome.py b/src/pyromaths/ex/lycee/ExoPolynome.py index 01e5bbf7..285cf825 100644 --- a/src/pyromaths/ex/lycee/ExoPolynome.py +++ b/src/pyromaths/ex/lycee/ExoPolynome.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,10 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div from random import randrange from pyromaths.classes.Polynome import Polynome, TeX, RacineDegre2 from pyromaths.classes.Racine import simplifie_racine @@ -92,7 +96,7 @@ def exo_racines_degre2(): return exo, cor exo_racines_degre2.description = _(u'Équations 2° degré') -exo_racines_degre2.level = _(u'1.1èreS') +exo_racines_degre2.level = _('1.1reS') def exo_factorisation_degre2(): @@ -171,7 +175,7 @@ def exo_factorisation_degre2(): return exo, cor exo_factorisation_degre2.description = _(u'Factorisations 2° degré') -exo_factorisation_degre2.level = _(u'1.1èreS') +exo_factorisation_degre2.level = _('1.1reS') def exo_factorisation_degre3(): @@ -206,7 +210,7 @@ def exo_factorisation_degre3(): return exo, cor exo_factorisation_degre3.description = _(u'Factorisations degré 3') -exo_factorisation_degre3.level = _(u'1.1èreS') +exo_factorisation_degre3.level = _('1.1reS') def exo_tableau_de_signe(): @@ -261,7 +265,7 @@ def exo_tableau_de_signe(): return exo, cor exo_tableau_de_signe.description = _(u'Étude de signe') -exo_tableau_de_signe.level = _(u'1.1èreS') +exo_tableau_de_signe.level = _('1.1reS') def exo_variation(): @@ -281,7 +285,7 @@ def exo_variation(): return exo, cor exo_variation.description = _(u"Sens de variations") -exo_variation.level = [_(u"1.1èreS"), _(u"0.Term STMG")] +exo_variation.level = [_("1.1reS"), _("0.Term STMG")] def exo_variation_lim(): @@ -300,7 +304,7 @@ def exo_variation_lim(): return exo, cor exo_variation_lim.description = _(u"Étude de fonctions") -exo_variation_lim.level = _(u"0.Term S") +exo_variation_lim.level = _("0.Term S") def quest_fonctions_rationnelles(): from pyromaths.classes.Fractions import Fraction @@ -434,7 +438,7 @@ def quest_fonctions_rationnelles_sur_R(): rac_min = -9 rac_max = 9 b1 = b2 = a1 = a2 = 0 - while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0 or a1 * (-float(b2) / a1) + b1 == 0 or (a1 * b2 / a2 - b1) == 0: + while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0 or a1 * (old_div(-float(b2), a1)) + b1 == 0 or (a1 * b2 / a2 - b1) == 0: # (a1*b2/a2 - b1)==0 on teste que la racine de Q n'annule pas P donc on ne peut pas simplifier b1 = randint(rac_min, rac_max) b2 = randint(rac_min, rac_max) @@ -872,7 +876,7 @@ def factorise_identites_remarquables(pol1, sgns, var='', racines=True): facteur3 = "" if a1 != 1: facteur3 += TeX(a1) - sgns = sgns / 2 + sgns = old_div(sgns, 2) if sgns: # (cx-b)² ou (cx+b)² liste_racines = [Fraction(-(sgns)) * b / c] facteur3 += "{(%s)}^2" % (c * X + sgns * b) @@ -1016,7 +1020,7 @@ def factorisation_degre3(E, nomE, exo=[], cor=[], racines=[0, 1, -1, 2, -2]): if x0 == 0: degre_facteur = min(E.puiss) # degre_facteur=1 - E2 = (E / (X ** degre_facteur))[0] + E2 = (old_div(E, (X ** degre_facteur)))[0] if degre_facteur == 1: cor.append(_("On remarque que $%s$ peut se factoriser par $%s$ et $%s=%s\\left(%s\\right)$") % (nomE, var, nomE, var, E2)) elif degre_facteur == 2: @@ -1028,7 +1032,7 @@ def factorisation_degre3(E, nomE, exo=[], cor=[], racines=[0, 1, -1, 2, -2]): else: cor.append(_("Comme $%s(%s)=0$, on peut diviser $%s$ par $%s$") % (nomE, TeX(x0), nomE, X - x0)) cor.append(TeX_division(E, (X - x0)) + "") - E2, reste = E / (X - x0) + E2, reste = old_div(E, (X - x0)) cor.append(_("\\item On doit maintenant factoriser le polynome $%s_2=%s$\\\\") % (nomE, E2)) delta, simplrac, racines, str_racines, factorisation = factorisation_degre2(E2, factorisation=True) cor = redaction_factorisation(E2, nomP=nomE + "_2", exo=[], cor=cor)[1] diff --git a/src/pyromaths/ex/lycee/ExoSecondDegre.py b/src/pyromaths/ex/lycee/ExoSecondDegre.py index 0ad3fa2e..62c5a897 100644 --- a/src/pyromaths/ex/lycee/ExoSecondDegre.py +++ b/src/pyromaths/ex/lycee/ExoSecondDegre.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -import sys, os, codecs -from pyromaths.classes.SecondDegre import Poly2 +from __future__ import unicode_literals from pyromaths.outils.Arithmetique import * def exo_second_degre(): diff --git a/src/pyromaths/ex/lycee/Fonction.py b/src/pyromaths/ex/lycee/Fonction.py index 81cde87d..c0828d7b 100644 --- a/src/pyromaths/ex/lycee/Fonction.py +++ b/src/pyromaths/ex/lycee/Fonction.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div from random import randrange def genere_points(xmin, xmax, ymin, ymax, simple=False): @@ -58,7 +63,7 @@ def bezier(simple=False, xmin=-15, xmax=15, ymin=-12, ymax=12): elif liste_points[i - 1][1] > liste_points[i][1]: points.append(liste_points[i]) deltaxx = 0.3 * (points[1][0] - points[0][0]) - nderiv = float(points[1][1] - points[0][1]) / (points[1][0] - points[0][0]) + nderiv = old_div(float(points[1][1] - points[0][1]), (points[1][0] - points[0][0])) apres = [(points[0][0] + 0.5, points[0][1] + deltaxx * nderiv)] avant = [] if points[0][1] < points[1][1]: @@ -80,7 +85,7 @@ def bezier(simple=False, xmin=-15, xmax=15, ymin=-12, ymax=12): y_variation.append(points[i][1]) variation += '-' else: - nderiv = float(points[i - 1][1] - points[i + 1][1]) / (points[i - 1][0] - points[i + 1][0]) + nderiv = old_div(float(points[i - 1][1] - points[i + 1][1]), (points[i - 1][0] - points[i + 1][0])) deltax = 0.3 * (points[i - 1][0] - points[i][0]) deltaxx = 0.3 * (points[i + 1][0] - points[i][0]) avant.append((points[i][0] + deltax, points[i][1] + deltax * nderiv)) @@ -90,7 +95,7 @@ def bezier(simple=False, xmin=-15, xmax=15, ymin=-12, ymax=12): for i in range(len(points) - 1): string += str(apres[i]) + str(avant[i]) + str(points[i + 1]) textbezier = "\\input{tabvar}\n\ - \psset{unit=" + str(14.0 / largeur) + "cm}\n\ + \psset{unit=" + str(old_div(14.0, largeur)) + "cm}\n\ \\begin{pspicture}" textbezier += "(" + str(xmin) + "," + str(ymin) + ")(" + str(liste_points[-1][0]) + "," + str(ymax) + ")\n" textbezier += "\psgrid[subgriddiv=0,griddots=10,gridlabels=0pt]\n\ @@ -154,7 +159,7 @@ def tab_var_poly(P, borneinf="-\\infty" , bornesup=u"+\\infty"): tab_var += "\\tx{f(" + P.var + ")}& &\\fd&\\cr\n" return tab_var + "}$$\n" elif P.deg == 2: - alpha = -P.dictio[1] / (2 * P.dictio[2]) + alpha = old_div(-P.dictio[1], (2 * P.dictio[2])) extremum = P(alpha) if (borneinf == "-\\infty" or Intervalle[0] < alpha) and\ (Intervalle[1] == "+\\infty" or Intervalle[1] > alpha): diff --git a/src/pyromaths/ex/lycee/SecondDegre.py b/src/pyromaths/ex/lycee/SecondDegre.py index 7b49d28b..4bec4777 100644 --- a/src/pyromaths/ex/lycee/SecondDegre.py +++ b/src/pyromaths/ex/lycee/SecondDegre.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div from pyromaths import ex from math import sqrt from random import shuffle, randrange @@ -28,6 +33,7 @@ from pyromaths.classes.PolynomesCollege import Polynome, factoriser from pyromaths.classes.SquareRoot import SquareRoot from pyromaths.outils.Arithmetique import carrerise, pgcd, valeur_alea +from functools import reduce """Exercice de seconde : Chapitre Second degré.""" @@ -45,7 +51,7 @@ def signe(nombre): class BilanTrinomeSansDiscriminant(Jinja2Exercice): description = u"Bilan sur les trinômes" - level = u"2.Seconde" + level = "2.Seconde" def __init__(self): super(BilanTrinomeSansDiscriminant, self).__init__() @@ -58,7 +64,7 @@ def __init__(self): b = -a * (x1 + x2) c = a * x1 * x2 - alpha = -b/(2*a) + alpha = old_div(-b,(2*a)) beta = a * (alpha**2) + b * alpha + c if alpha == 0 or beta == 0: @@ -78,7 +84,7 @@ def __init__(self): "x2": x2, "alpha": alpha, "absalpha": abs(alpha), # Valeur absolue de alpha - "signealpha": alpha/abs(alpha), # Signe de alpha (qui est non nul) + "signealpha": old_div(alpha,abs(alpha)), # Signe de alpha (qui est non nul) "beta": beta, } @@ -132,7 +138,7 @@ def creerPolydegre2(nb_racines=2, rac_radical=True, rac_quotient=False): class Sd1FormeCanonique(ex.TexExercise): description = _(u'Forme canonique') - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): m = [[1, 2], [2 * randrange(1, 10) * (-1) ** randrange(2), 1], [randrange(1, 10) * (-1) ** randrange(2), 0]] @@ -160,11 +166,11 @@ def __init__(self): def resolution(self, m, pre=[], post=[]): sgn = '+-'[m[1][0] < 0] if isinstance(m[1][0], Fraction): - b = Priorites3.priorites(abs(m[1][0]) / 2)[-1][0] + b = Priorites3.priorites(old_div(abs(m[1][0]), 2))[-1][0] elif m[1][0] % 2: b = 'Fraction(%s, 2)' % abs(m[1][0]) else: - b = abs(m[1][0]) / 2 + b = old_div(abs(m[1][0]), 2) fc = ['Polynome("%sx%s%s")' % (m[0][0], sgn, b), '**', '2'] reste = ['-'] if m[2][0] > 0 or isinstance(m[2][0], Fraction): @@ -268,8 +274,9 @@ def tex_answer(self): return exo class Sd2aRacines(ex.TexExercise): + #TODO: ./utils/pyromaths-cli.py generate Sd2aRacines:1, 2 et 3 ne fonctionnent pas description = _(u'Racines d\'un polynôme de degré 2') - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): pol = [creerPolydegre2(nb_racines=2, rac_radical=True, rac_quotient=False)] pol.append(creerPolydegre2(nb_racines=1)) @@ -391,7 +398,7 @@ def tex_answer(self): class Sd2bEquations(ex.TexExercise): # description = u'Équations et polynômes de degré 2' - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): pol = [creerPolydegre2(nb_racines=2, rac_radical=False, rac_quotient=False)] pol.append(creerPolydegre2(nb_racines=1)) @@ -433,7 +440,7 @@ def tex_statement(self): class Sd3aSigne(ex.TexExercise): # description = u'Signe d\'un polynôme de degré 2' - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): pol = [[valeur_alea(-9, 9), 2 - dummy] for dummy in range(3)] while pol[1][0] ** 2 - 4 * pol[0][0] * pol[2][0] >= 0: @@ -445,8 +452,8 @@ def __init__(self): while val[2].d == 1: val = [valeur_alea(-9, 9), valeur_alea(-9, 9)] val.append(Fraction(valeur_alea(-9, 9), val[0])) - sgn = -val[0] / abs(val[0]) - pol = [[val[0], 2], [(-val[0] * (val[1] * val[2].d + val[2].n)) / val[2].d, 1], [(val[0] * val[1] * val[2].n) / val[2].d, 0]] + sgn = old_div(-val[0], abs(val[0])) + pol = [[val[0], 2], [old_div((-val[0] * (val[1] * val[2].d + val[2].n)), val[2].d), 1], [old_div((val[0] * val[1] * val[2].n), val[2].d), 0]] shuffle(pol) exercice.append([pol, val[1], val[2]]) @@ -455,7 +462,7 @@ def __init__(self): while isinstance(val[2], int) or val[2].d == 1: val = [sgn * valeur_alea(-9, 9), valeur_alea(-9, 9)] val.append(Fraction(valeur_alea(-9, 9), val[0])) - pol = [[val[0], 2], [(-val[0] * (val[1] * val[2].d + val[2].n)) / val[2].d, 1], [(val[0] * val[1] * val[2].n) / val[2].d, 0]] + pol = [[val[0], 2], [old_div((-val[0] * (val[1] * val[2].d + val[2].n)), val[2].d), 1], [old_div((val[0] * val[1] * val[2].n), val[2].d), 0]] shuffle(pol) exercice.append([pol, val[1], val[2]]) @@ -474,7 +481,7 @@ def tex_statement(self): class Sd3bInequations(ex.TexExercise): # description = u'Inéquations et polynômes de degré 2' - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): pol = creerPolydegre2(nb_racines=2, rac_radical=False, rac_quotient=False).monomes pol2 = [[valeur_alea(-9, 9), 1], [valeur_alea(-9, 9), 0]] @@ -494,7 +501,7 @@ def tex_statement(self): class Sd4Factorisation(ex.TexExercise): # description = u'Racines et factorisation d\'un polynôme de degré 2' - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): val = [valeur_alea(-9, 9), valeur_alea(-9, 9)] val.append(Fraction(valeur_alea(-9, 9), val[0])) @@ -502,7 +509,7 @@ def __init__(self): val = [valeur_alea(-9, 9), valeur_alea(-9, 9)] val.append(Fraction(valeur_alea(-9, 9), val[0])) - pol = [[val[0], 2], [(-val[0] * (val[1] * val[2].d + val[2].n)) / val[2].d, 1], [(val[0] * val[1] * val[2].n) / val[2].d, 0]] + pol = [[val[0], 2], [old_div((-val[0] * (val[1] * val[2].d + val[2].n)), val[2].d), 1], [old_div((val[0] * val[1] * val[2].n), val[2].d), 0]] shuffle(pol) exercice = [[list(pol), val[1], val[2]]] @@ -537,11 +544,11 @@ def tex_statement(self): class Sd5Caracteristiques(ex.TexExercise): # description = u'Caractéristiques d\'une parabole' - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): val = [valeur_alea(-9, 9), valeur_alea(-9, 9) , valeur_alea(-9, 9)] pol = Polynome([[val[0], 2], [(-val[0] * (val[1] + val[2])), 1], [(val[0] * val[1] * val[2]), 0]]) - while val[2] == val[1] or abs(val[0] * val[1] * val[2]) > 10 or abs(eval(pol((val[1] + val[2]) / 2.))) > 10: + while val[2] == val[1] or abs(val[0] * val[1] * val[2]) > 10 or abs(eval(pol(old_div((val[1] + val[2]), 2.)))) > 10: val = [valeur_alea(-9, 9), valeur_alea(-9, 9) , valeur_alea(-9, 9)] pol = Polynome([[val[0], 2], [(-val[0] * (val[1] + val[2])), 1], [(val[0] * val[1] * val[2]), 0]]) val = [[val[0], 2], [(-val[0] * (val[1] + val[2])), 1], [(val[0] * val[1] * val[2]), 0]] @@ -574,7 +581,7 @@ def tex_statement(self): class Sd6Parametre(ex.TexExercise): # description = u'Polynôme paramétré de degré 2' - level = _(u"1.1èreS") + level = _("1.1reS") def __init__(self): [a, b, c, d] = [randrange(-5, 6) for dummy in range(4)] while a == 0 or c == 0 or a ** 2 * d - a * b * c + c ** 2 < 0 or carrerise(a ** 2 * d - a * b * c + c ** 2) != 1: @@ -587,7 +594,7 @@ def __init__(self): v = [randrange(-4, 5) for dummy in range(6)] while v[0] == 0 or v[2] == v[4] == 0 or reduce(lambda x, y: x * y, v) != 0 or v[2] == v[3] == 0 or v[4] == v[5] == 0: v = [randrange(-4, 5) for dummy in range(6)] - lp = [str(Polynome([[v[2 * i] / pgcd(v[2 * i], v[2 * i + 1]), 1], [v[2 * i + 1] / pgcd(v[2 * i], v[2 * i + 1]), 0]], "a")) for i in range(3)] + lp = [str(Polynome([[old_div(v[2 * i], pgcd(v[2 * i], v[2 * i + 1])), 1], [old_div(v[2 * i + 1], pgcd(v[2 * i], v[2 * i + 1])), 0]], "a")) for i in range(3)] pol = Polynome([[lp[0], 2], [lp[1], 1], [lp[2], 0]]) vi = Fraction(-v[1], v[0]) racine = randrange(-4, 5) diff --git a/src/pyromaths/ex/lycee/Statitisiques.py b/src/pyromaths/ex/lycee/Statitisiques.py index 79ed7b10..a0c8bc1b 100644 --- a/src/pyromaths/ex/lycee/Statitisiques.py +++ b/src/pyromaths/ex/lycee/Statitisiques.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -25,6 +25,9 @@ @author: jerome ''' +from __future__ import unicode_literals +from builtins import str +from builtins import range from pyromaths import ex from random import randrange def listeToclasses(liste): @@ -39,7 +42,7 @@ class Histogramme(ex.TexExercise): classdocs ''' # description = u'Construire un histogramme' - # level = u"2.Seconde" + # level = "2.Seconde" def __init__(self): diff --git a/src/pyromaths/ex/lycee/TermesSuite.py b/src/pyromaths/ex/lycee/TermesSuite.py index 97cfd361..f8da6783 100644 --- a/src/pyromaths/ex/lycee/TermesSuite.py +++ b/src/pyromaths/ex/lycee/TermesSuite.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,12 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from builtins import object +from past.utils import old_div import functools import random import textwrap @@ -60,9 +66,9 @@ 10: u"à dix fois le", } NOTATIONS = [ - ur"u", - ur"\left(u_n\right)", - ur"\left(u_n\right)_{n\in\mathbb{N}}", + "u", + r"\left(u_n\right)", + r"\left(u_n\right)_{n\in\mathbb{N}}", ] def signe(nombre): @@ -72,7 +78,7 @@ def signe(nombre): return -1 raise ValueError -class Fraction: +class Fraction(object): def __init__(self, numerateur, denominateur, signe=1): self.signe = signe self.numerateur = numerateur @@ -86,7 +92,7 @@ def latex(self): signe = "" else: signe = "-" - return ur"{}\frac{{ {} }}{{ {} }}".format( + return r"{}\frac{{ {} }}{{ {} }}".format( signe, self.numerateur, self.denominateur, @@ -97,8 +103,8 @@ def simplifie(self): return Entier(self.signe * self.numerateur / self.denominateur) diviseur = pgcd(self.numerateur, self.denominateur) return Fraction( - self.numerateur/diviseur, - self.denominateur/diviseur, + old_div(self.numerateur,diviseur), + old_div(self.denominateur,diviseur), self.signe, ) @@ -108,7 +114,7 @@ def __float__(self): @functools.total_ordering -class Entier: +class Entier(object): def __init__(self, valeur): self.valeur = valeur @@ -169,7 +175,7 @@ def __float__(self): Fraction(4, 5), ] -class Fonction: +class Fonction(object): def calcul(self, argument): raise NotImplementedError() @@ -186,7 +192,7 @@ def __init__(self): self.coeff = random.choice(FRACTIONS) def expression(self, variable): - return ur"{coeff}{variable}".format( + return r"{coeff}{variable}".format( coeff=self.coeff.latex(), variable=variable, ) @@ -194,10 +200,10 @@ def expression(self, variable): def calcul(self, argument): if isinstance(argument, Entier): if float(argument) < 0: - arg = ur"\left( {} \right)".format(argument.latex()) + arg = r"\left( {} \right)".format(argument.latex()) else: arg = argument.latex() - yield self.expression(ur"\times " + arg) + yield self.expression(r"\times " + arg) if isinstance(self.coeff.simplifie(), Fraction): yield Fraction( self.coeff.numerateur * argument.valeur, @@ -208,7 +214,7 @@ def calcul(self, argument): else: yield self.resultat(argument).latex() else: - yield self.expression(ur"\times " + argument.latex()) + yield self.expression(r"\times " + argument.latex()) yield Fraction( self.coeff.numerateur * argument.numerateur, self.coeff.denominateur * argument.denominateur, @@ -237,7 +243,7 @@ def __init__(self): self.ordonnee = Entier(ordonnee) def expression(self, variable): - return ur"{coeff}{variable}{ordonnee}".format( + return r"{coeff}{variable}{ordonnee}".format( coeff=self.coeff.latex(), ordonnee=self.ordonnee.latex("+"), variable=variable, @@ -245,13 +251,13 @@ def expression(self, variable): def calcul(self, argument): if float(argument) < 0: - arg = ur"\left( {} \right)".format(argument.latex()) + arg = r"\left( {} \right)".format(argument.latex()) else: arg = argument.latex() - yield self.expression(ur"\times " + arg) + yield self.expression(r"\times " + arg) if isinstance(argument, Entier): if isinstance(self.coeff.simplifie(), Fraction): - yield ur"{fraction} {signe} \frac{{ {ordonnee} \times {denom} }}{{ {denom} }}".format( + yield r"{fraction} {signe} \frac{{ {ordonnee} \times {denom} }}{{ {denom} }}".format( fraction=Fraction( self.coeff.numerateur * argument.valeur, self.coeff.denominateur, @@ -260,13 +266,13 @@ def calcul(self, argument): denom=self.coeff.denominateur, signe=Entier(self.coeff.denominateur * self.ordonnee.valeur).latex("+")[0], ) - yield ur"\frac{{ {gauche} {droite} }}{{ {denom} }}".format( + yield r"\frac{{ {gauche} {droite} }}{{ {denom} }}".format( gauche=self.coeff.numerateur * argument.valeur, droite=Entier(self.coeff.denominateur * self.ordonnee.valeur).latex("+"), denom=self.coeff.denominateur, ) else: - yield ur"{} + \frac{{ {} \times {} }}{{ {} }}".format( + yield r"{} + \frac{{ {} \times {} }}{{ {} }}".format( Fraction( self.coeff.numerateur * argument.numerateur, self.coeff.denominateur * argument.denominateur, @@ -275,7 +281,7 @@ def calcul(self, argument): self.coeff.denominateur * argument.denominateur, self.coeff.denominateur * argument.denominateur, ) - yield ur"\frac{{ {} {} }}{{ {} }}".format( + yield r"\frac{{ {} {} }}{{ {} }}".format( self.coeff.numerateur * argument.numerateur, Entier(self.ordonnee.valeur * self.coeff.denominateur * argument.denominateur).latex("+"), self.coeff.denominateur * argument.denominateur, @@ -297,7 +303,7 @@ def __init__(self): self.denominateur = Entier(random.randint(2, 10)) def expression(self, variable): - return ur"\frac{{ {numerateur}^{variable} }}{{ {denominateur}{variable} }}".format( + return r"\frac{{ {numerateur}^{variable} }}{{ {denominateur}{variable} }}".format( numerateur=self.numerateur.latex("-"), denominateur=self.denominateur.latex("-"), variable=variable, @@ -305,16 +311,16 @@ def expression(self, variable): def calcul(self, argument): if argument.valeur < 0: - arg2 = ur"\left( {} \right)".format(argument.latex()) + arg2 = r"\left( {} \right)".format(argument.latex()) else: arg2 = argument.latex() - yield ur"\frac{{ {numerateur}^{{ {argument} }}}}{{ {denominateur}\times{arg2} }}".format( + yield r"\frac{{ {numerateur}^{{ {argument} }}}}{{ {denominateur}\times{arg2} }}".format( numerateur=self.numerateur.latex(), denominateur=self.denominateur.latex(), argument=argument.latex(), arg2=arg2, ) - yield ur"\frac{{ {} }}{{ {} }}".format( + yield r"\frac{{ {} }}{{ {} }}".format( self.numerateur.valeur ** argument.valeur, self.denominateur.valeur * argument.valeur, ) @@ -341,21 +347,21 @@ def __init__(self): self.coef = [Entier(i) for i in coef] def expression(self, variable): - return ur"{coef[2]}{variable}^2{coef[1]}{variable}{coef[0]}".format( + return r"{coef[2]}{variable}^2{coef[1]}{variable}{coef[0]}".format( coef=[self.coef[0].latex("+"), self.coef[1].latex("+"), self.coef[2].latex("-")], variable=variable, ) def calcul(self, argument): if argument < 0: - texargument = ur"\left{{ {variable} }}".format(argument.latex()) + texargument = r"\left{{ {variable} }}".format(argument.latex()) else: texargument = argument.latex() - yield ur"{coef[2]}\times{argument}^2{coef[1]}\times{argument}{coef[0]}".format( + yield r"{coef[2]}\times{argument}^2{coef[1]}\times{argument}{coef[0]}".format( coef=[self.coef[0].latex("+"), self.coef[1].latex("+"), self.coef[2].latex("-")], argument=texargument, ) - yield ur"{}{}{}".format( + yield r"{}{}{}".format( Entier(self.coef[2].valeur * argument.valeur**2).latex(), Entier(self.coef[1].valeur * argument.valeur).latex("+"), Entier(self.coef[0].valeur).latex("+") @@ -379,7 +385,7 @@ def __init__(self): self.ordonnee = Entier(ordonnee) def expression(self, variable): - return ur"{variable}{ordonnee}".format( + return r"{variable}{ordonnee}".format( variable=variable, ordonnee=self.ordonnee.latex("+"), ) @@ -408,10 +414,10 @@ def francais(self): def expression(self, variable): # L'argument est du code LaTeX - return ur"{} {}".format(self.raison.latex(), variable) + return r"{} {}".format(self.raison.latex(), variable) def calcul(self, argument): - yield ur"{} \times {}".format(self.raison.latex(), argument.latex()) + yield r"{} \times {}".format(self.raison.latex(), argument.latex()) resultat = self.resultat(argument).latex() if isinstance(resultat, Entier): yield self.resultat(argument).latex() @@ -423,16 +429,16 @@ def calcul(self, argument): raison = Fraction(raison.valeur, 1) numerateur = argument.numerateur * raison.numerateur denominateur = raison.denominateur * argument.denominateur - yield ur"\frac{{ {} }}{{ {} }}".format(numerateur, denominateur) + yield r"\frac{{ {} }}{{ {} }}".format(numerateur, denominateur) if numerateur % denominateur == 0: - yield Entier(numerateur / denominateur).latex() + yield Entier(old_div(numerateur, denominateur)).latex() return diviseur = pgcd(numerateur, denominateur) if diviseur == 1: return - yield Fraction(numerateur/diviseur, denominateur/diviseur).latex() + yield Fraction(old_div(numerateur,diviseur), old_div(denominateur,diviseur)).latex() def resultat(self, argument): if isinstance(argument, Entier) and isinstance(self.raison, Entier): @@ -447,9 +453,9 @@ def resultat(self, argument): numerateur = argument.numerateur * raison.numerateur denominateur = raison.denominateur * argument.denominateur if numerateur % denominateur == 0: - return Entier(numerateur / denominateur) + return Entier(old_div(numerateur, denominateur)) diviseur = pgcd(numerateur, denominateur) - return Fraction(numerateur/diviseur, denominateur/diviseur) + return Fraction(old_div(numerateur,diviseur), old_div(denominateur,diviseur)) class FrancaisArithmetique(Fonction): @@ -467,7 +473,7 @@ def francais(self): def expression(self, variable): # L'argument est du code LaTeX - return ur"{} {}".format(variable, Entier(self.raison).latex("+")) + return r"{} {}".format(variable, Entier(self.raison).latex("+")) def calcul(self, argument): yield self.expression(argument.latex()) @@ -484,10 +490,10 @@ def francais(self): def expression(self, variable): # L'argument est du code LaTeX - if variable < 0: - return ur"-\left({}\right)".format(variable) + if variable.startswith("-"): + return r"-\left({}\right)".format(variable) else: - return ur"-{}".format(variable) + return r"-{}".format(variable) def calcul(self, argument): yield Entier(-argument.valeur).latex("-") @@ -505,14 +511,14 @@ def francais(self): def expression(self, variable): # L'argument est du code LaTeX - return ur"\frac{{1}}{{ {} }}".format(variable) + return r"\frac{{1}}{{ {} }}".format(variable) def calcul(self, argument): yield self.expression(argument.latex()) if isinstance(argument, Entier) and argument > 0: pass elif isinstance(argument, Entier) and argument < 0: - yield ur"-{}".format(self.expression((-argument).latex())) + yield r"-{}".format(self.expression((-argument).latex())) elif isinstance(argument, Fraction): yield self.resultat(argument).latex() else: @@ -579,7 +585,7 @@ def __init__(self, indice0): def latex_params(self): return { 'indice0': self.indice0, - 'fonction': self.fonction.expression(ur"n"), + 'fonction': self.fonction.expression(r"n"), 'notation': self.notation, } @@ -599,21 +605,21 @@ def latex_params(self): return { 'indice0': self.indice0, 'terme0': self.terme0.latex("-"), - 'fonction': self.fonction.expression(ur"u_n"), + 'fonction': self.fonction.expression(r"u_n"), 'notation': self.notation, } class TermesDUneSuite(ex.TexExercise): description = u"Termes d'une suite" - level = u"1.1èreS" + level = "1.1reS" def __init__(self): # * `self.rang[0]` désigne l'ordinal du premier terme demandé (pour la # première question de chacune des trois suites) ; # * `self.rang[1]` et `self.rang[2]` sont les rangs demandés pour les # deux questions suivantes dans chacune des trois suites. - self.rang = [random.randint(2, 7)] + random.sample(range(3, 7), 2) + self.rang = [random.randint(2, 7)] + random.sample(list(range(3, 7)), 2) self.questions = [ Francais(random.randint(0, min(self.rang[1:])-1)), @@ -623,33 +629,33 @@ def __init__(self): def tex_statement(self): exo = [r'\exercice'] - exo.append(ur'Pour chacune des suites $u$ suivantes, calculer :') - exo.append(ur' (a) le {} terme ;'.format(FRANCAIS_ORDINAL[self.rang[0]])) - exo.append(ur' (b) le terme de rang {} ;'.format(self.rang[1])) - exo.append(ur' (c) $u_{}$.'.format(self.rang[2])) - - exo.append(ur'\begin{enumerate}') - exo.append(ur' \item ${notation}$ est une suite de premier terme $u_{indice0}={terme0}$, et dont chaque terme (sauf le premier) est égal {suivant}.'.format(**self.questions[0].latex_params)) - exo.append(ur' \item ${notation}$ est la suite définie pour $n\geq{indice0}$ par : $u_n={fonction}$.'.format(**self.questions[1].latex_params)) - exo.append(textwrap.dedent(ur""" + exo.append(r'Pour chacune des suites $u$ suivantes, calculer :') + exo.append(r' (a) le {} terme ;'.format(FRANCAIS_ORDINAL[self.rang[0]])) + exo.append(r' (b) le terme de rang {} ;'.format(self.rang[1])) + exo.append(r' (c) $u_{}$.'.format(self.rang[2])) + + exo.append(r'\begin{enumerate}') + exo.append(r' \item ${notation}$ est une suite de premier terme $u_{indice0}={terme0}$, et dont chaque terme (sauf le premier) est égal {suivant}.'.format(**self.questions[0].latex_params)) + exo.append(r' \item ${notation}$ est la suite définie pour $n\geq{indice0}$ par : $u_n={fonction}$.'.format(**self.questions[1].latex_params)) + exo.append(textwrap.dedent(r""" \item ${notation}$ est la suite définie pour $n\geq{indice0}$ par : \[\left\{{\begin{{array}}{{l}} u_{indice0}={terme0}\\ \text{{Pour tout $n\geq{indice0}$ : }} u_{{n+1}}={fonction}. \end{{array}}\right.\] """).format(**self.questions[2].latex_params)) - exo.append(ur'\end{enumerate}') + exo.append(r'\end{enumerate}') return exo def tex_answer(self): exo = [r'\exercice*'] - exo.append(ur'\begin{enumerate}') + exo.append(r'\begin{enumerate}') # Question 0 - exo.append(ur" \item Selon l'énoncé, le premier terme de ${notation}$ est $u_{indice0}={terme0}$. Puisque chaque terme (sauf le premier) est égal {suivant}, on a :".format(**self.questions[0].latex_params)) + exo.append(r" \item Selon l'énoncé, le premier terme de ${notation}$ est $u_{indice0}={terme0}$. Puisque chaque terme (sauf le premier) est égal {suivant}, on a :".format(**self.questions[0].latex_params)) termes = dict([(self.questions[0].indice0, self.questions[0].terme0)]) calcul_termes = [] - for indice in xrange(self.questions[0].indice0, max(self.rang[0] + self.questions[0].indice0 - 1, self.rang[1], self.rang[2])): - calcul = ur"$u_{indice}={fonction}".format( + for indice in range(self.questions[0].indice0, max(self.rang[0] + self.questions[0].indice0 - 1, self.rang[1], self.rang[2])): + calcul = r"$u_{indice}={fonction}".format( indice=indice+1, fonction=self.questions[0].fonction.expression("u_{}".format(indice)), ) @@ -659,54 +665,54 @@ def tex_answer(self): termes[indice+1] = self.questions[0].fonction.resultat(termes[indice]) calcul_termes.append(calcul) exo.append(" ; ".join(calcul_termes) + ".") - exo.append(ur'\begin{enumerate}') - exo.append(ur' \item Calcul du {} terme :'.format(FRANCAIS_ORDINAL[self.rang[0]])) + exo.append(r'\begin{enumerate}') + exo.append(r' \item Calcul du {} terme :'.format(FRANCAIS_ORDINAL[self.rang[0]])) enumeration = [] for indice in range(0, self.rang[0]): enumeration.append(u"le {ordinal} terme est $u_{indice}$".format(ordinal=FRANCAIS_ORDINAL[indice+1], indice=self.questions[0].indice0+indice)) exo.append(" ; ".join(enumeration) + ".") - exo.append(ur"Le terme demandé est donc : $u_{}={}$.".format(self.rang[0] + self.questions[0].indice0 - 1, termes[self.rang[0] + self.questions[0].indice0 - 1].latex())) - exo.append(ur'\item Le terme de rang {indice} est : $u_{indice}={valeur}$.'.format(indice=self.rang[1], valeur=termes[self.rang[1]].latex())) - exo.append(ur'\item Nous avons calculé que : $u_{indice}={valeur}$.'.format(indice=self.rang[2], valeur=termes[self.rang[2]].latex())) - exo.append(ur'\end{enumerate}') + exo.append(r"Le terme demandé est donc : $u_{}={}$.".format(self.rang[0] + self.questions[0].indice0 - 1, termes[self.rang[0] + self.questions[0].indice0 - 1].latex())) + exo.append(r'\item Le terme de rang {indice} est : $u_{indice}={valeur}$.'.format(indice=self.rang[1], valeur=termes[self.rang[1]].latex())) + exo.append(r'\item Nous avons calculé que : $u_{indice}={valeur}$.'.format(indice=self.rang[2], valeur=termes[self.rang[2]].latex())) + exo.append(r'\end{enumerate}') # Question 1 - exo.append(ur' \item La suite ${notation}$ est définie pour $n\geq{indice0}$ par : $u_n={fonction}$.'.format(**self.questions[1].latex_params)) - exo.append(ur"Elle est donc définie par son terme général : pour calculer un terme de rang $n$, on peut calculer directement l'image de $n$ par la suite.") - exo.append(ur'\begin{enumerate}') - exo.append(ur' \item Calcul du {} terme :'.format(FRANCAIS_ORDINAL[self.rang[0]])) + exo.append(r' \item La suite ${notation}$ est définie pour $n\geq{indice0}$ par : $u_n={fonction}$.'.format(**self.questions[1].latex_params)) + exo.append(r"Elle est donc définie par son terme général : pour calculer un terme de rang $n$, on peut calculer directement l'image de $n$ par la suite.") + exo.append(r'\begin{enumerate}') + exo.append(r' \item Calcul du {} terme :'.format(FRANCAIS_ORDINAL[self.rang[0]])) enumeration = [] for indice in range(0, self.rang[0]): enumeration.append(u"le {ordinal} terme est $u_{indice}$".format(ordinal=FRANCAIS_ORDINAL[indice+1], indice=self.questions[1].indice0+indice)) exo.append(" ; ".join(enumeration) + ".") - exo.append(ur"Le terme demandé est donc : $u_{}=".format(self.rang[0] + self.questions[1].indice0 - 1)) + exo.append(r"Le terme demandé est donc : $u_{}=".format(self.rang[0] + self.questions[1].indice0 - 1)) calcul = [] for etape in self.questions[1].fonction.calcul(Entier(self.rang[0] + self.questions[1].indice0 - 1)): calcul.append(etape) - exo.append(u" = ".join(calcul) + ur"$.") - exo.append(ur"La solution est $u_{{ {} }}={}$.".format(self.rang[0] + self.questions[1].indice0 - 1, self.questions[1].fonction.resultat(Entier(self.rang[0] + self.questions[1].indice0 - 1)).latex())) - exo.append(ur"\item Le terme de rang {rang} est $u_{{ {rang} }}$.".format(rang=self.rang[1])) + exo.append(u" = ".join(calcul) + r"$.") + exo.append(r"La solution est $u_{{ {} }}={}$.".format(self.rang[0] + self.questions[1].indice0 - 1, self.questions[1].fonction.resultat(Entier(self.rang[0] + self.questions[1].indice0 - 1)).latex())) + exo.append(r"\item Le terme de rang {rang} est $u_{{ {rang} }}$.".format(rang=self.rang[1])) if self.rang[0] + self.questions[1].indice0 - 1 == self.rang[1]: - exo.append(ur"Ce terme a déjà été calculé, et $u_{{ {} }}={}$.".format(self.rang[1], self.questions[1].fonction.resultat(Entier(self.rang[1])).latex())) + exo.append(r"Ce terme a déjà été calculé, et $u_{{ {} }}={}$.".format(self.rang[1], self.questions[1].fonction.resultat(Entier(self.rang[1])).latex())) else: calcul = [] for etape in self.questions[1].fonction.calcul(Entier(self.rang[1])): calcul.append(etape) - exo.append(ur"Le terme demandé est donc : $u_{{ {} }}=".format(self.rang[1]) + " = ".join(calcul) + ur"$.") - exo.append(ur"La solution est donc : $u_{{ {} }}={}$.".format(self.rang[1], self.questions[1].fonction.resultat(Entier(self.rang[1])).latex())) - exo.append(ur"\item") + exo.append(r"Le terme demandé est donc : $u_{{ {} }}=".format(self.rang[1]) + " = ".join(calcul) + r"$.") + exo.append(r"La solution est donc : $u_{{ {} }}={}$.".format(self.rang[1], self.questions[1].fonction.resultat(Entier(self.rang[1])).latex())) + exo.append(r"\item") if self.rang[0] + self.questions[1].indice0 - 1 == self.rang[2]: - exo.append(ur"Ce terme a déjà été calculé, et $u_{{ {} }}={}$.".format(self.rang[2], self.questions[1].fonction.resultat(Entier(self.rang[2])).latex())) + exo.append(r"Ce terme a déjà été calculé, et $u_{{ {} }}={}$.".format(self.rang[2], self.questions[1].fonction.resultat(Entier(self.rang[2])).latex())) else: calcul = [] for etape in self.questions[1].fonction.calcul(Entier(self.rang[2])): calcul.append(etape) - exo.append(ur"On a : $u_{{ {} }}=".format(self.rang[2]) + " = ".join(calcul) + ur"$.") - exo.append(ur"La solution est donc : $u_{{ {} }}={}$.".format(self.rang[2], self.questions[1].fonction.resultat(Entier(self.rang[2])).latex())) - exo.append(ur'\end{enumerate}') + exo.append(r"On a : $u_{{ {} }}=".format(self.rang[2]) + " = ".join(calcul) + r"$.") + exo.append(r"La solution est donc : $u_{{ {} }}={}$.".format(self.rang[2], self.questions[1].fonction.resultat(Entier(self.rang[2])).latex())) + exo.append(r'\end{enumerate}') # Question 2 - exo.append(textwrap.dedent(ur""" + exo.append(textwrap.dedent(r""" \item La suite ${notation}$ est définie par récurrence, pour $n\geq{indice0}$, par : \[\left\{{\begin{{array}}{{l}} u_{indice0}={terme0}\\ @@ -715,8 +721,8 @@ def tex_answer(self): """).format(**self.questions[2].latex_params)) termes = dict([(self.questions[2].indice0, self.questions[2].terme0)]) calcul_termes = [] - for indice in xrange(self.questions[2].indice0, max(self.rang[0] + self.questions[2].indice0 - 1, self.rang[1], self.rang[2])): - calcul = ur"u_{indice} &= {fonction}".format( + for indice in range(self.questions[2].indice0, max(self.rang[0] + self.questions[2].indice0 - 1, self.rang[1], self.rang[2])): + calcul = r"u_{indice} &= {fonction}".format( indice=indice+1, fonction=self.questions[2].fonction.expression("u_{}".format(indice)), ) @@ -724,19 +730,19 @@ def tex_answer(self): calcul += " =" + etape termes[indice+1] = self.questions[2].fonction.resultat(termes[indice]) calcul_termes.append(calcul) - exo.append(ur"\begin{align*}") - exo.append(ur" \\".join(calcul_termes)) - exo.append(ur"\end{align*}") - exo.append(ur'\begin{enumerate}') - exo.append(ur' \item Calcul du {} terme :'.format(FRANCAIS_ORDINAL[self.rang[0]])) + exo.append(r"\begin{align*}") + exo.append(r" \\".join(calcul_termes)) + exo.append(r"\end{align*}") + exo.append(r'\begin{enumerate}') + exo.append(r' \item Calcul du {} terme :'.format(FRANCAIS_ORDINAL[self.rang[0]])) enumeration = [] for indice in range(0, self.rang[0]): enumeration.append(u"le {ordinal} terme est $u_{indice}$".format(ordinal=FRANCAIS_ORDINAL[indice+1], indice=self.questions[2].indice0+indice)) exo.append(" ; ".join(enumeration) + ".") - exo.append(ur"Le terme demandé est donc : $u_{}={}$.".format(self.rang[0] + self.questions[2].indice0 - 1, termes[self.rang[0] + self.questions[2].indice0 - 1].latex())) - exo.append(ur'\item Le terme de rang {indice} est : $u_{indice}={valeur}$.'.format(indice=self.rang[1], valeur=termes[self.rang[1]].latex())) - exo.append(ur'\item Nous avons calculé que : $u_{indice}={valeur}$.'.format(indice=self.rang[2], valeur=termes[self.rang[2]].latex())) - exo.append(ur'\end{enumerate}') + exo.append(r"Le terme demandé est donc : $u_{}={}$.".format(self.rang[0] + self.questions[2].indice0 - 1, termes[self.rang[0] + self.questions[2].indice0 - 1].latex())) + exo.append(r'\item Le terme de rang {indice} est : $u_{indice}={valeur}$.'.format(indice=self.rang[1], valeur=termes[self.rang[1]].latex())) + exo.append(r'\item Nous avons calculé que : $u_{indice}={valeur}$.'.format(indice=self.rang[2], valeur=termes[self.rang[2]].latex())) + exo.append(r'\end{enumerate}') - exo.append(ur'\end{enumerate}') + exo.append(r'\end{enumerate}') return exo diff --git a/src/pyromaths/ex/lycee/VariationsFonctions.py b/src/pyromaths/ex/lycee/VariationsFonctions.py index 833ffee8..a0259fbb 100644 --- a/src/pyromaths/ex/lycee/VariationsFonctions.py +++ b/src/pyromaths/ex/lycee/VariationsFonctions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div from pyromaths import ex from random import randrange, shuffle #=============================================================================== @@ -29,7 +34,6 @@ # from pyromaths.classes.SquareRoot import SquareRoot from pyromaths.outils.Arithmetique import valeur_alea from pyromaths.outils.Affichage import decimaux -from string import zfill #=============================================================================== def PointsCourbes(sens_var=(-1, -1, 0, 1, 1), nb_var=(3, 5), absc=(-5, 5), ordo=(-4, 4), cstes=(0, 1)): @@ -110,7 +114,7 @@ def integration_zeros(lX, lY, variations): class Vf1SensEtTableau(ex.TexExercise): description = _(u'Sens et Tableau de variations') - level = _(u"2.Seconde") + level = _("2.Seconde") def __init__(self): lX = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] @@ -130,8 +134,8 @@ def tex_statement(self): exo.append('\\begin{asy}\n import graph;\n import interpolate;\n unitsize(5mm);') exo.append(r'defaultpen(fontsize(9pt));') exo.append(r'real[] xpt,ypt;') - exo.append(r'real [] xpt={%s};' % (",".join([zfill(str(a), 2) for a in self.lX]))) - exo.append(r'real [] ypt={%s};' % (",".join([zfill(str(a), 2) for a in self.lY1]))) + exo.append(r'real [] xpt={%s};' % (",".join([str(a).zfill(2) for a in self.lX]))) + exo.append(r'real [] ypt={%s};' % (",".join([str(a).zfill(2) for a in self.lY1]))) exo.append(r'xlimits(-6.2, 6.2);') exo.append(r'ylimits(-5.2, 5.2);') exo.append(r'xaxis(axis=BottomTop, p=invisible,') @@ -156,8 +160,8 @@ def tex_statement(self): exo.append('\\begin{asy}\n import graph;\n import interpolate;\n unitsize(5mm);') exo.append(r'defaultpen(fontsize(9pt));') exo.append(r'real[] xpt,ypt;') - exo.append(r'real [] xpt={%s};' % (",".join([zfill(str(a), 2) for a in self.lX]))) - exo.append(r'real [] ypt={%s};' % (",".join([zfill(str(a), 2) for a in self.lY2]))) + exo.append(r'real [] xpt={%s};' % (",".join([str(a).zfill(2) for a in self.lX]))) + exo.append(r'real [] ypt={%s};' % (",".join([str(a).zfill(2) for a in self.lY2]))) exo.append(r'xlimits(-6.2, 6.2);') exo.append(r'ylimits(-5.2, 5.2);') exo.append(r'xaxis(axis=BottomTop, p=invisible,') @@ -188,9 +192,9 @@ def tex_answer(self): ans = _(u'\\item la fonction $f$ est') dvar = {_(u'décroissante'): [], _(u'croissante'): [], _(u'constante'):[]} for v in self.variations1: - if v[0] == 1: dvar[_(u'croissante')].append('$[%s~;~%s]$' % (v[1], v[2])) - elif v[0] == -1: dvar[_(u'décroissante')].append('$[%s~;~%s]$' % (v[1], v[2])) - elif v[0] == 0: dvar[_(u'constante')].append('$[%s~;~%s]$' % (v[1], v[2])) + if v[0] == 1: dvar[_(u'croissante')].append('$\interval{%s}{%s}$' % (v[1], v[2])) + elif v[0] == -1: dvar[_(u'décroissante')].append('$\interval{%s}{%s}$' % (v[1], v[2])) + elif v[0] == 0: dvar[_(u'constante')].append('$\interval{%s}{%s}$' % (v[1], v[2])) else: raise ValueError(_('variation non attendue')) if dvar[_(u'décroissante')]: ans += u' décroissante sur %s,' % ' et '.join(dvar[_(u'décroissante')]) if dvar[_(u'croissante')]: ans += u' croissante sur %s' % ' et '.join(dvar[_(u'croissante')]) @@ -265,7 +269,7 @@ def extrema(lX, lY, intervalle): class Vf2ExtremaGraphiques(ex.TexExercise): description = _(u'Extrema et représentation graphique') - level = _(u"2.Seconde") + level = _("2.Seconde") def __init__(self): fin = False @@ -307,17 +311,17 @@ def tex_statement(self): exo.append(r'\begin{multicols}{2}') exo.append(r'\begin{enumerate}') exo.append(_(u'\\item Quels sont les extrema de la fonction $f$ ?')) - exo.append(_(u'\\item Quel est le %s de $f$ sur l\'intervalle $[%s~;~%s]$ ?') % (self.extremum, self.intervalle1[0], self.intervalle1[1])) + exo.append(_(u'\\item Quel est le %s de $f$ sur l\'intervalle $\interval{%s}{%s}$ ?') % (self.extremum, self.intervalle1[0], self.intervalle1[1])) exo.append(_(u'\\item Quels sont les extrema de la fonction $g$ ?')) - exo.append(_(u'\\item Quels sont les extrema de $g$ sur l\'intervalle $[%s~;~%s]$ ?') % (self.intervalle2[0], self.intervalle2[1])) + exo.append(_(u'\\item Quels sont les extrema de $g$ sur l\'intervalle $\interval{%s}{%s}$ ?') % (self.intervalle2[0], self.intervalle2[1])) exo.append(r'\end{enumerate}') exo.append(r'\end{multicols}') exo.append(r'\begin{center}') exo.append('\\begin{asy}\n import graph;\n import interpolate;\n unitsize(5mm);') exo.append(r'defaultpen(fontsize(9pt));') exo.append(r'real[] xpt,ypt;') - exo.append(r'real [] xpt={%s};' % (",".join([zfill(str(a), 2) for a in self.lX]))) - exo.append(r'real [] ypt={%s};' % (",".join([zfill(str(a), 2) for a in self.lY1]))) + exo.append(r'real [] xpt={%s};' % (",".join([str(a).zfill(2) for a in self.lX]))) + exo.append(r'real [] ypt={%s};' % (",".join([str(a).zfill(2) for a in self.lY1]))) exo.append(r'xlimits(-6.2, 6.2);') exo.append(r'ylimits(-5.2, 5.2);') exo.append(r'xaxis(axis=BottomTop, p=invisible,') @@ -342,8 +346,8 @@ def tex_statement(self): exo.append('\\begin{asy}\n import graph;\n import interpolate;\n unitsize(5mm);') exo.append(r'defaultpen(fontsize(9pt));') exo.append(r'real[] xpt,ypt;') - exo.append(r'real [] xpt={%s};' % (",".join([zfill(str(a), 2) for a in self.lX]))) - exo.append(r'real [] ypt={%s};' % (",".join([zfill(str(a), 2) for a in self.lY2]))) + exo.append(r'real [] xpt={%s};' % (",".join([str(a).zfill(2) for a in self.lX]))) + exo.append(r'real [] ypt={%s};' % (",".join([str(a).zfill(2) for a in self.lY2]))) exo.append(r'xlimits(-6.2, 6.2);') exo.append(r'ylimits(-5.2, 5.2);') exo.append(r'xaxis(axis=BottomTop, p=invisible,') @@ -373,30 +377,30 @@ def tex_answer(self): extr = extrema(self.lX, self.lY1, [self.lX[0], self.lX[-1]]) exo.append(u'\\item ') exo.append(r'\begin{itemize}[leftmargin=*]') - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{maximum} de $f$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[1][1], extr[1][0])) - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{minimum} de $f$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[0][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{maximum} de $f$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[1][1], extr[1][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{minimum} de $f$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[0][0])) exo.append(r'\end{itemize}') extr = extrema(self.lX, self.lY1, self.intervalle1) extr = extr[self.extremum == "maximum"] - exo.append(_(u'\\item Sur $[%s~;~%s]$, le \\textbf{%s} de $f$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$. ') % (self.intervalle1[0], self.intervalle1[1], self.extremum, extr[1], extr[0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$, le \\textbf{%s} de $f$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$. ') % (self.intervalle1[0], self.intervalle1[1], self.extremum, extr[1], extr[0])) extr = extrema(self.lX, self.lY2, [self.lX[0], self.lX[-1]]) exo.append(u'\\item ') exo.append(r'\begin{itemize}[leftmargin=*]') - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{maximum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[1][1], extr[1][0])) - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{minimum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[0][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{maximum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[1][1], extr[1][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{minimum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[0][0])) exo.append(r'\end{itemize}') extr = extrema(self.lX, self.lY2, self.intervalle2) exo.append(u'\\item ') exo.append(r'\begin{itemize}[leftmargin=*]') - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{maximum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.intervalle2[0], self.intervalle2[1], extr[1][1], extr[1][0])) - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{minimum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.intervalle2[0], self.intervalle2[1], extr[0][1], extr[0][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{maximum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.intervalle2[0], self.intervalle2[1], extr[1][1], extr[1][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{minimum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.intervalle2[0], self.intervalle2[1], extr[0][1], extr[0][0])) exo.append(r'\end{itemize}') exo.append(r'\end{enumerate}') return exo class Vf3VariationVersCourbe(ex.TexExercise): description = _(u'Tableaux de variations et courbe') - level = _(u"2.Seconde") + level = _("2.Seconde") def __init__(self): lX = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] @@ -502,19 +506,19 @@ def tex_answer(self): sneg, spos = '', '' for i in lneg: if i[1] == i[0]: lneg.remove(i) - else: sneg += '$[%s~;~%s]$, ' % (i[0], i[1]) + else: sneg += '$\interval{%s}{%s}$, ' % (i[0], i[1]) sneg = sneg[:-2] for i in lpos: if i[1] == i[0]: lpos.remove(i) - else: spos += '$[%s~;~%s]$, ' % (i[0], i[1]) + else: spos += '$\interval{%s}{%s}$, ' % (i[0], i[1]) spos = spos[:-2] exo.append(_(u'\\item La fonction $f$ est \\textbf{négative} sur %s et \\textbf{positive} sur %s.') % (sneg, spos)) extr = extrema(self.lX, self.lY2, [self.lX[0], self.lX[-1]]) exo.append(r'\item') exo.append(r'\begin{itemize}[leftmargin=*]') - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{maximum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[1][1], extr[1][0])) - exo.append(_(u'\\item Sur $[%s~;~%s]$ , le \\textbf{minimum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[0][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{maximum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[1][1], extr[1][0])) + exo.append(_(u'\\item Sur $\interval{%s}{%s}$ , le \\textbf{minimum} de $g$ est $y = %s$. Il est \\textbf{atteint en} $x = %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[0][0])) exo.append(r'\end{itemize}') exo.append(r'\end{enumerate}') exo.append(r'\item\ ') @@ -525,8 +529,8 @@ def tex_answer(self): exo.append(r'defaultpen(fontsize(9pt));') exo.append(r'real[] xpt,ypt;') lAbsc, lOrdo = integration_zeros(self.lX, self.lY1, self.variations1) - exo.append(r'real [] xpt={%s};' % (",".join([zfill(str(a), 2) for a in lAbsc]))) - exo.append(r'real [] ypt={%s};' % (",".join([zfill(str(a), 2) for a in lOrdo]))) + exo.append(r'real [] xpt={%s};' % (",".join([str(a).zfill(2) for a in lAbsc]))) + exo.append(r'real [] ypt={%s};' % (",".join([str(a).zfill(2) for a in lOrdo]))) exo.append(r'xlimits(-6.2, 6.2);') exo.append(r'ylimits(-5.2, 5.2);') exo.append(r'xaxis(axis=BottomTop, p=invisible,') @@ -554,8 +558,8 @@ def tex_answer(self): exo.append(r'defaultpen(fontsize(9pt));') exo.append(r'real[] xpt,ypt;') lAbsc, lOrdo = integration_zeros(self.lX, self.lY2, self.variations2) - exo.append(r'real [] xpt={%s};' % (",".join([zfill(str(a), 2) for a in lAbsc]))) - exo.append(r'real [] ypt={%s};' % (",".join([zfill(str(a), 2) for a in lOrdo]))) + exo.append(r'real [] xpt={%s};' % (",".join([str(a).zfill(2) for a in lAbsc]))) + exo.append(r'real [] ypt={%s};' % (",".join([str(a).zfill(2) for a in lOrdo]))) exo.append(r'xlimits(-6.2, 6.2);') exo.append(r'ylimits(-5.2, 5.2);') exo.append(r'xaxis(axis=BottomTop, p=invisible,') @@ -588,8 +592,8 @@ def elements_intervalle(variations, sens): index = randrange(len(variations)) if variations[index][0] == sens: break - x0 = decimaux(randrange(50 * variations[index][1] // 6 + 10 * variations[index][2] // 6, 20 * variations[index][1] // 3 + 10 * variations[index][2] // 3 + 1) / 10., True) - x1 = decimaux(randrange(10 * variations[index][1] // 3 + 20 * variations[index][2] // 3, 10 * variations[index][1] // 6 + 50 * variations[index][2] // 6, +1) / 10., True) + x0 = decimaux(old_div(randrange(50 * variations[index][1] // 6 + 10 * variations[index][2] // 6, 20 * variations[index][1] // 3 + 10 * variations[index][2] // 3 + 1), 10.), True) + x1 = decimaux(old_div(randrange(10 * variations[index][1] // 3 + 20 * variations[index][2] // 3, 10 * variations[index][1] // 6 + 50 * variations[index][2] // 6, +1), 10.), True) return [x0, x1, [variations[index][1], variations[index][2]]] def non_monotone(variations, lX, lY, signe): @@ -608,17 +612,17 @@ def non_monotone(variations, lX, lY, signe): i1 = tirage.pop(randrange(len(tirage))) except ValueError: return None - x0 = randrange(10 * variations[i0][1] + 1, 10 * variations[i0][2]) / 10. - x1 = randrange(10 * variations[i1][1] + 1, 10 * variations[i1][2]) / 10. + x0 = old_div(randrange(10 * variations[i0][1] + 1, 10 * variations[i0][2]), 10.) + x1 = old_div(randrange(10 * variations[i1][1] + 1, 10 * variations[i1][2]), 10.) for i in range(len(lX)): if x0 <= lX[i]: if x0 == lX[i]: y0 = lY[i] - else: y0 = (lY[i - 1] + lY[i]) / 2. + else: y0 = old_div((lY[i - 1] + lY[i]), 2.) break for i in range(len(lX)): if x1 <= lX[i]: if x1 == lX[i]: y1 = lY[i] - else: y1 = (lY[i - 1] + lY[i]) / 2. + else: y1 = old_div((lY[i - 1] + lY[i]), 2.) break if signe and y0 * y1 <= 0: return ([x0, y0], [x1, y1]) if not signe and y0 * y1 > 0: @@ -637,7 +641,7 @@ def intersection_intervalles(I0, I1): class Vf4ComparerImages(ex.TexExercise): description = _(u'Comparer des images à partir du sens de variation') - level = _(u"2.Seconde") + level = _("2.Seconde") def __init__(self): fin = False @@ -734,16 +738,16 @@ def tex_answer(self): exo.append(r'\item') exo.append(r'\begin{enumerate}') for i in range(3): - exo.append(_(u'\\item $f\\,(%s) %s f\\,(%s)$ car $%s < %s$ et $f$ est %s sur $[%s~;~%s]$.') % (self.comparaison[i][0], ['=', '<', '>'][self.comparaison[i][3]], self.comparaison[i][1], self.comparaison[i][0], self.comparaison[i][1], [_(u'constante'), _(u'croissante'), _(u'décroissante')][self.comparaison[i][3]], self.comparaison[i][2][0], self.comparaison[i][2][1])) + exo.append(_(u'\\item $f\\,(%s) %s f\\,(%s)$ car $%s < %s$ et $f$ est %s sur $\interval{%s}{%s}$.') % (self.comparaison[i][0], ['=', '<', '>'][self.comparaison[i][3]], self.comparaison[i][1], self.comparaison[i][0], self.comparaison[i][1], [_(u'constante'), _(u'croissante'), _(u'décroissante')][self.comparaison[i][3]], self.comparaison[i][2][0], self.comparaison[i][2][1])) exo.append(r'\end{enumerate}') for i in range(2): if self.non_comparable[i][0][1] * self.non_comparable[i][1][1] <= 0: - exo.append(_(u'\\item $f\\,(%s) %s f\\,(%s)$ car d’après le signe de la fonction $f\\,(%s) %s 0$ et $f\\,(%s) %s 0$ (par contre, on ne peut pas utiliser le sens de variation qui change sur l’intervalle $[%s~;~%s]$).') % \ + exo.append(_(u'\\item $f\\,(%s) %s f\\,(%s)$ car d’après le signe de la fonction $f\\,(%s) %s 0$ et $f\\,(%s) %s 0$ (par contre, on ne peut pas utiliser le sens de variation qui change sur l’intervalle $\interval{%s}{%s}$).') % \ (decimaux(self.non_comparable[i][0][0], 1), ['<', '>'][self.non_comparable[i][0][1] > 0], decimaux(self.non_comparable[i][1][0], 1), \ decimaux(self.non_comparable[i][0][0], 1), ['<', '>'][self.non_comparable[i][0][1] > 0], decimaux(self.non_comparable[i][1][0], 1), \ ['<', '>'][self.non_comparable[i][1][1] > 0], decimaux(min(self.non_comparable[i][0][0], self.non_comparable[i][1][0]), 1), decimaux(max(self.non_comparable[i][0][0], self.non_comparable[i][1][0]), 1))) else: - exo.append(_(u'\\item On ne peut pas comparer $f\\,(%s)$ et $f\\,(%s)$ car la fonction $f$ n\'est pas monotone (elle change de sens de variation) sur $[%s~;~%s]$.') % \ + exo.append(_(u'\\item On ne peut pas comparer $f\\,(%s)$ et $f\\,(%s)$ car la fonction $f$ n\'est pas monotone (elle change de sens de variation) sur $\interval{%s}{%s}$.') % \ (decimaux(self.non_comparable[i][0][0], 1), decimaux(self.non_comparable[i][1][0], 1), decimaux(self.non_comparable[i][0][0], 1), decimaux(self.non_comparable[i][1][0], 1))) exo.append(r'\end{enumerate}') return exo @@ -758,17 +762,17 @@ def extrema_locaux(variations, lX, lY): tirage = [a for a in range(len(variations))] i0 = tirage.pop(randrange(len(tirage))) i1 = tirage.pop(randrange(len(tirage))) - x0 = randrange(10 * variations[i0][1] + 1, 10 * variations[i0][2]) / 10. - x1 = randrange(10 * variations[i1][1] + 1, 10 * variations[i1][2]) / 10. + x0 = old_div(randrange(10 * variations[i0][1] + 1, 10 * variations[i0][2]), 10.) + x1 = old_div(randrange(10 * variations[i1][1] + 1, 10 * variations[i1][2]), 10.) for i in range(len(lX)): if x0 <= lX[i]: if x0 == lX[i]: y0 = lY[i] - else: y0 = (lY[i - 1] + lY[i]) / 2. + else: y0 = old_div((lY[i - 1] + lY[i]), 2.) break for i in range(len(lX)): if x1 <= lX[i]: if x1 == lX[i]: y1 = lY[i] - else: y1 = (lY[i - 1] + lY[i]) / 2. + else: y1 = old_div((lY[i - 1] + lY[i]), 2.) break extremums = [100, -100] # extremums = [min(variations[i0][1], variations[i1][1]), max(variations[i0][2], variations[i1][2])] @@ -796,7 +800,7 @@ def extrema_locaux(variations, lX, lY): class Vf5Extrema_Tableau(ex.TexExercise): description = _(u'Extrema locaux à partir du tableau de variation') - level = _(u"2.Seconde") + level = _("2.Seconde") def __init__(self): fin = False @@ -811,9 +815,9 @@ def __init__(self): if comparaison[0] != None and comparaison[1] != None: fin = True self.comparaison = comparaison - inegalites = ['\\ge', '\\le'] + inegalites = ['\\geqslant{}', '\\leqslant{}'] shuffle(inegalites) - inegalites.append(['\\le', '\\ge'][randrange(2)]) + inegalites.append(['\\leqslant{}', '\\geqslant{}'][randrange(2)]) self.inegalites = inegalites def tex_statement(self): @@ -822,15 +826,15 @@ def tex_statement(self): exo.append(_(u'\\item À partir du tableau de variation de la fonction $f$, compléter les égalités ou inégalités suivantes :\\vspace{-2ex}')) exo.append(r'\begin{multicols}{2}') exo.append(r'\begin{enumerate}') - exo.append(r'\item Pour $x \in [%s~;~%s],\quad f\,(x) %s \ldots{}$' % (self.lX[0], self.lX[-1], self.inegalites[0])) - exo.append(r'\item Pour $x \in [%s~;~%s],\quad f\,(x) %s \ldots{}$' % (self.lX[0], self.lX[-1], self.inegalites[1])) - exo.append(r'\item Pour $x \in [%s~;~%s],\quad f\,(x) %s \ldots{}$' % (decimaux(self.comparaison[0][0][0], 1), decimaux(self.comparaison[0][1][0], 1), self.inegalites[2])) + exo.append(r'\item Pour $x \in \interval{%s}{%s},\quad f\,(x) %s \ldots{}$' % (self.lX[0], self.lX[-1], self.inegalites[0])) + exo.append(r'\item Pour $x \in \interval{%s}{%s},\quad f\,(x) %s \ldots{}$' % (self.lX[0], self.lX[-1], self.inegalites[1])) + exo.append(r'\item Pour $x \in \interval{%s}{%s},\quad f\,(x) %s \ldots{}$' % (decimaux(self.comparaison[0][0][0], 1), decimaux(self.comparaison[0][1][0], 1), self.inegalites[2])) exo.append(r'\end{enumerate}') exo.append(r'\end{multicols}') exo.append(u'\\item') exo.append(r'\begin{enumerate}') - exo.append(_(u'\\item Donner un encadrement de la fonction $f$ sur l’intervalle $[%s~;~%s]$.') % (self.lX[0], self.lX[-1])) - exo.append(_(u'\\item Donner un encadrement de la fonction $f$ sur l’intervalle $[%s~;~%s]$.') % (decimaux(self.comparaison[1][0][0], 1), decimaux(self.comparaison[1][1][0], 1))) + exo.append(_(u'\\item Donner un encadrement de la fonction $f$ sur l’intervalle $\interval{%s}{%s}$.') % (self.lX[0], self.lX[-1])) + exo.append(_(u'\\item Donner un encadrement de la fonction $f$ sur l’intervalle $\interval{%s}{%s}$.') % (decimaux(self.comparaison[1][0][0], 1), decimaux(self.comparaison[1][1][0], 1))) exo.append(r'\end{enumerate}') exo.append(r'\end{enumerate}') exo.append(r'\begin{center}') @@ -889,15 +893,15 @@ def tex_answer(self): exo.append(r'\begin{multicols}{2}') exo.append(r'\begin{enumerate}') extr = extrema(self.lX, self.lY, [self.lX[0], self.lX[-1]]) - exo.append(_(r'\item Pour $x \in [%s~;~%s],\quad f\,(x) %s %s$') % (self.lX[0], self.lX[-1], self.inegalites[0], extr['\\le' == self.inegalites[0]][1])) - exo.append(_(r'\item Pour $x \in [%s~;~%s],\quad f\,(x) %s %s$') % (self.lX[0], self.lX[-1], self.inegalites[1], extr['\\le' == self.inegalites[1]][1])) - exo.append(_(r'\item Pour $x \in [%s~;~%s],\quad f\,(x) %s %s$') % (decimaux(self.comparaison[0][0][0], 1), decimaux(self.comparaison[0][1][0], 1), self.inegalites[2], self.comparaison[0][2]['\\le' == self.inegalites[2]])) + exo.append(_(r'\item Pour $x \in \interval{%s}{%s},\quad f\,(x) %s %s$') % (self.lX[0], self.lX[-1], self.inegalites[0], extr['\\leqslant{}' == self.inegalites[0]][1])) + exo.append(_(r'\item Pour $x \in \interval{%s}{%s},\quad f\,(x) %s %s$') % (self.lX[0], self.lX[-1], self.inegalites[1], extr['\\leqslant{}' == self.inegalites[1]][1])) + exo.append(_(r'\item Pour $x \in \interval{%s}{%s},\quad f\,(x) %s %s$') % (decimaux(self.comparaison[0][0][0], 1), decimaux(self.comparaison[0][1][0], 1), self.inegalites[2], self.comparaison[0][2]['\\le' == self.inegalites[2]])) exo.append(r'\end{enumerate}') exo.append(r'\end{multicols}') exo.append(r'\item') exo.append(r'\begin{enumerate}') - exo.append(_(u'\\item Sur $[%s~;~%s],\\quad %s \\le f\\,(x) \\le %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[1][1])) - exo.append(_(u'\\item Sur $[%s~;~%s],\\quad %s \\le f\\,(x) \\le %s$.') % (decimaux(self.comparaison[1][0][0], 1), decimaux(self.comparaison[1][1][0], 1), decimaux(self.comparaison[1][2][0], 1), decimaux(self.comparaison[1][2][1], 1))) + exo.append(_(u'\\item Sur $\interval{%s}{%s},\\quad %s \\leqslant{} f\\,(x) \\leqslant{} %s$.') % (self.lX[0], self.lX[-1], extr[0][1], extr[1][1])) + exo.append(_(u'\\item Sur $\interval{%s}{%s},\\quad %s \\leqslant{} f\\,(x) \\leqslant{} %s$.') % (decimaux(self.comparaison[1][0][0], 1), decimaux(self.comparaison[1][1][0], 1), decimaux(self.comparaison[1][2][0], 1), decimaux(self.comparaison[1][2][1], 1))) exo.append(r'\end{enumerate}') exo.append(r'\end{enumerate}') diff --git a/src/pyromaths/ex/lycee/Vecteurs.py b/src/pyromaths/ex/lycee/Vecteurs.py index eedf890f..75ca3c78 100644 --- a/src/pyromaths/ex/lycee/Vecteurs.py +++ b/src/pyromaths/ex/lycee/Vecteurs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -30,6 +30,10 @@ # #- simplifier des sommes # #- problèmes de colinéarité +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from past.utils import old_div from pyromaths.classes.Vecteurs import randvect, Vecteur from pyromaths.classes.Racine import simplifie_racine import math @@ -51,17 +55,17 @@ def pair(n): def AffNom(u, crd=0): '''Renvoie les coordonnées pour l'affichage du nom du vecteur u.''' if u.x == 0 and math.fabs(u.y) > 2: - coord = (0, u.y / 2) + coord = (0, old_div(u.y, 2)) elif u.x == 0: - coord = (-0.5, u.y / 2) + coord = (-0.5, old_div(u.y, 2)) elif u.y == 0 and math.fabs(u.x) > 2: - coord = (u.x / 2, 0) + coord = (old_div(u.x, 2), 0) elif u.y == 0: - coord = (u.x / 2, -0.5) + coord = (old_div(u.x, 2), -0.5) elif math.fabs(u.x) + math.fabs(u.y) < 3: - coord = (u.x / 2.0 + 0.5, u.y / 2.0 + 0.5) + coord = (old_div(u.x, 2.0) + 0.5, old_div(u.y, 2.0) + 0.5) else: - coord = (u.x / 2, u.y / 2) + coord = (old_div(u.x, 2), old_div(u.y, 2)) return str(coord[0]) + "," + str(coord[1]) def ChoixVecteur(u, v, w, x, y): @@ -86,7 +90,7 @@ def repr_somme(u, v, u1, u2, cor, larg=0): if (a.x > 0): departx = 0 elif (a.x == 0): - departx = -u.x / 2.0 + math.fabs(u.x) / 2 + departx = old_div(-u.x, 2.0) + old_div(math.fabs(u.x), 2) else: departx = max(math.fabs(u.x), math.fabs(a.x)) else: @@ -100,7 +104,7 @@ def repr_somme(u, v, u1, u2, cor, larg=0): if (a.y > 0): departy = 0 elif (a.y == 0): - departy = -u.y / 2.0 + math.fabs(u.y) / 2 + departy = old_div(-u.y, 2.0) + old_div(math.fabs(u.y), 2) else: departy = max(math.fabs(u.y), math.fabs(a.y)) else: diff --git a/src/pyromaths/ex/lycee/__init__.py b/src/pyromaths/ex/lycee/__init__.py index de3b5d15..942ac9ab 100644 --- a/src/pyromaths/ex/lycee/__init__.py +++ b/src/pyromaths/ex/lycee/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,5 +20,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -description = _(u'2.Lycée') +from __future__ import unicode_literals +description = _('2.Lycée') level = description diff --git a/src/pyromaths/ex/lycee/equations.py b/src/pyromaths/ex/lycee/equations.py index 7065fff1..72c8c8b5 100644 --- a/src/pyromaths/ex/lycee/equations.py +++ b/src/pyromaths/ex/lycee/equations.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -19,7 +19,14 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from __builtin__ import str +from __future__ import division +from __future__ import unicode_literals +from future import standard_library +standard_library.install_aliases() +from builtins import str +from builtins import range +from past.utils import old_div +from builtins import str ''' Created on 1 janv. 2015 @@ -69,9 +76,9 @@ def __init__(self): l1.pop(randrange(len(l1))) if l1[2] - l1[1] > 3 and l1[1] - l1[0] > 3: encore = False pos = randrange(2) - l2 = randrange(1, 4) / 2. + l2 = old_div(randrange(1, 4), 2.) l2 = [l1[pos] + l2, l1[pos + 1] - l2] - l3 = [(l1[(pos + 1) % 2] + l1[(pos + 1) % 2 + 1]) / 2.] + l3 = [old_div((l1[(pos + 1) % 2] + l1[(pos + 1) % 2 + 1]), 2.)] l1.extend(l2) l1.extend(l3) y = [randrange(2) * (-1) ** randrange(2), randrange(3, 5) * (-1) ** randrange(2)] diff --git a/src/pyromaths/ex/lycee/matrices.py b/src/pyromaths/ex/lycee/matrices.py index 3c57a93d..2ca3be81 100644 --- a/src/pyromaths/ex/lycee/matrices.py +++ b/src/pyromaths/ex/lycee/matrices.py @@ -23,8 +23,11 @@ # """Exercice de Terminale ES, spécialité : Déterminer un état stable en utilisant un système.""" +from __future__ import division +from __future__ import unicode_literals -import decimal +from past.utils import old_div +from decimal import Decimal import random from pyromaths.ex import Jinja2Exercice @@ -33,35 +36,35 @@ # Liste des coefficients de la diagonale de la matrice de transition qui # donnent des états stables dont la valeur exacte a au plus trois décimales. CANDIDATS = [ - [.45, .30], - [.50, .25], - [.55, .20], - [.55, .25], - [.60, .15], - [.65, .10], - [.70, .05], - [.70, .10], - [.70, .50], - [.70, .55], - [.75, .45], - [.80, .40], - [.80, .70], - [.85, .40], - [.85, .55], - [.85, .65], - [.85, .75], - [.90, .30], - [.95, .55], - [.95, .65], - [.95, .80], - [.95, .85], + [".45", ".3 "], + [".5 ", ".25"], + [".55", ".2 "], + [".55", ".25"], + [".6 ", ".15"], + [".65", ".1 "], + [".7 ", ".05"], + [".7 ", ".1 "], + [".7 ", ".5 "], + [".7 ", ".55"], + [".75", ".45"], + [".8 ", ".4 "], + [".8 ", ".7 "], + [".85", ".4 "], + [".85", ".55"], + [".85", ".65"], + [".85", ".75"], + [".9 ", ".3 "], + [".95", ".55"], + [".95", ".65"], + [".95", ".8 "], + [".95", ".85"], ] class EtatStableSysteme2(Jinja2Exercice): description = u"Recherche d'état stable (avec un système)" - level = u"0.Term ES" + level = "0.Term ES" def __init__(self): super(EtatStableSysteme2, self).__init__() @@ -69,8 +72,8 @@ def __init__(self): ab = random.choice(CANDIDATS) random.shuffle(ab) self.context = { - "a": ab[0], - "b": ab[1], + "a": Decimal(ab[0]), + "b": Decimal(ab[1]), } @property @@ -85,7 +88,7 @@ class InterpolationMatrices(Jinja2Exercice): # Plus ou moins inspiré du sujet de bac ES Amérique du Nord, juin 2015. description = u"Interpolation polynomiale en utilisant des matrices" - level = u"0.Term ES" + level = "0.Term ES" def __init__(self): super(InterpolationMatrices, self).__init__() @@ -100,9 +103,9 @@ def __init__(self): a = b = c = 0 while True: - a = decimal.Decimal(random.choice([1, -1]) * random.randint(2, 19)) - b = decimal.Decimal(random.choice([1, -1]) * random.randint(2, 19)) - c = decimal.Decimal(random.choice([1, -1]) * random.randint(2, 19)) + a = Decimal(random.choice([1, -1]) * random.randint(2, 19)) + b = Decimal(random.choice([1, -1]) * random.randint(2, 19)) + c = Decimal(random.choice([1, -1]) * random.randint(2, 19)) if len(set([a, b, c])) != 3: continue @@ -111,9 +114,9 @@ def __init__(self): break if random.randint(0, 1) == 1: - a = a / 10 - b = b / 10 - c = c / 10 + a = old_div(a, 10) + b = old_div(b, 10) + c = old_div(c, 10) M = [ [X[0]**2, X[0], 1], diff --git a/src/pyromaths/ex/quatriemes/__init__.py b/src/pyromaths/ex/quatriemes/__init__.py index 7c153d9f..f7741927 100644 --- a/src/pyromaths/ex/quatriemes/__init__.py +++ b/src/pyromaths/ex/quatriemes/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,5 +20,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -description = u'4.Quatrième' +from __future__ import unicode_literals +description = '4.Quatrième' level = description diff --git a/src/pyromaths/ex/quatriemes/calcul_mental.py b/src/pyromaths/ex/quatriemes/calcul_mental.py index 400e421f..ad473ee4 100644 --- a/src/pyromaths/ex/quatriemes/calcul_mental.py +++ b/src/pyromaths/ex/quatriemes/calcul_mental.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -24,6 +24,8 @@ # Pyromaths : Poser des opérations #---------------------------------------------------------------------- +from __future__ import unicode_literals +from builtins import range from pyromaths.outils import Arithmetique from pyromaths.outils.Affichage import tex_coef import random diff --git a/src/pyromaths/ex/quatriemes/fractions.py b/src/pyromaths/ex/quatriemes/fractions.py index aacd3e5b..f5bd1727 100644 --- a/src/pyromaths/ex/quatriemes/fractions.py +++ b/src/pyromaths/ex/quatriemes/fractions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,10 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div from pyromaths.outils import Arithmetique from pyromaths.outils.Priorites3 import texify, priorites import random @@ -32,7 +36,7 @@ def valeurs_somme_positive(): op = "+-"[random.randrange(2)] n2, d2 = random.randrange(1, 11), random.randrange(2, 11) - if op == "-" and 1 - n2 / d2 > 0: + if op == "-" and 1 - old_div(n2, d2) > 0: l.append('1 %s Fraction(%s, %s)' % (op, n2, d2)) else: l.append('Fraction(%s, %s) %s 1' % (n2, d2, op)) @@ -40,15 +44,15 @@ def valeurs_somme_positive(): op = "+-"[random.randrange(2)] n1 = random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) - if op == "-" and n1 - n2 / d2 > 0: + if op == "-" and n1 - old_div(n2, d2) > 0: l.append('%s %s Fraction(%s, %s)' % (n1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s %s' % (n2, d2, op, n1)) op = "+-"[random.randrange(2)] - n1 = random.randrange(1, 9) + random.randrange(1, 9) / 10. + n1 = random.randrange(1, 9) + old_div(random.randrange(1, 9), 10.) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) - if op == "-" and n1 - n2 / d2 > 0: + if op == "-" and n1 - old_div(n2, d2) > 0: l.append('%s %s Fraction(%s, %s)' % (n1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s %s' % (n2, d2, op, n1)) @@ -64,7 +68,7 @@ def valeurs_somme_positive(): op = "+-"[random.randrange(2)] n1, d1 = random.randrange(1, 11), random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) * d1 - if op == "-" and n1 / d1 - n2 / d2 > 0: + if op == "-" and old_div(n1, d1) - old_div(n2, d2) > 0: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n1, d1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n2, d2, op, n1, d1)) @@ -77,7 +81,7 @@ def valeurs_somme_positive(): n1, d1 = random.randrange(1, 11), random.randrange(2, 11) n2, d2 = random.randrange(1, 11), random.randrange(2, 11) lepgcd = Arithmetique.pgcd(d1, d2) - if op == "-" and n1 / d1 - n2 / d2 > 0: + if op == "-" and old_div(n1, d1) - old_div(n2, d2) > 0: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n1, d1, op, n2, d2)) else: l.append('Fraction(%s, %s) %s Fraction(%s, %s)' % (n2, d2, op, n1, d1)) diff --git a/src/pyromaths/ex/quatriemes/geometrie.py b/src/pyromaths/ex/quatriemes/geometrie.py index b79e3142..a2041fd1 100644 --- a/src/pyromaths/ex/quatriemes/geometrie.py +++ b/src/pyromaths/ex/quatriemes/geometrie.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,12 +20,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import random from math import acos, asin, atan, pi, sin, cos, tan +from fractions import Fraction from pyromaths.outils.Geometrie import couples_pythagore, choix_points - # # ------------------- THEOREME DE PYTHAGORE ------------------- def fig_tr_rect(lg): @@ -35,8 +40,7 @@ def fig_tr_rect(lg): b = a + 180 else: b = a - 180 - c = (int((180 - ((2 * acos((lg[1] * 1.0) / lg[2])) * 180) / pi) * - 100) * 1.0) / 100 + a + c = float(Fraction(int((180 - 2 * acos(lg[1] * 1.0 / lg[2]) * 180 / pi) * 100), 100) + a) if c < 0: c = c + 360 return (str(a), str(b), str(c)) @@ -86,7 +90,7 @@ def exo_pythagore(): for j in range(2): while True: longueurs = couples_pythagore[random.randrange(len(couples_pythagore))] - longueurs = [longueurs[i] / 10.0 for i in range(3)] + longueurs = [old_div(longueurs[i], 10.0) for i in range(3)] if inegalite_triangulaire(longueurs): break noms = choix_points(3) @@ -98,8 +102,7 @@ def exo_pythagore(): """ \\item Soit $%s$ un triangle rectangle en $%s$ tel que :\\par $%s=\\unit[%s]{cm}$ et $%s=\\unit[%s]{cm}$.\\par Calculer la longueur $%s$.""" % \ - enonce_pythagore(noms, angles, longueurs, cotes, nom_tr, long0, - long1) + enonce_pythagore(noms, angles, longueurs, cotes, nom_tr, long0, long1) exo.append(enonce) cor.append(enonce) cor.append("\\par\\dotfill{}\\par\n") @@ -173,7 +176,7 @@ def exo_triangle_cercle(): cor = ["\\exercice*"] while True: longueurs = couples_pythagore[random.randrange(len(couples_pythagore))] - longueurs = [longueurs[i] / 10.0 for i in range(3)] + longueurs = [old_div(longueurs[i], 10.0) for i in range(3)] if inegalite_triangulaire(longueurs): break noms = choix_points(3) @@ -197,8 +200,7 @@ def exo_triangle_cercle(): $\\big(\\mathcal{C}\\big)$ est un cercle de diamètre $[%s]$ et $%s$ est un point de $\\big(\\mathcal{C}\\big)$.\\par On donne $%s=\\unit[%s]{cm}$ et $%s=\\unit[%s]{cm}$.\\par Calculer la longueur $%s$.""" % \ - enonce_pythagore(noms, angles, longueurs, cotes, nom_tr, long0, - long1, diam=1) + enonce_pythagore(noms, angles, longueurs, cotes, nom_tr, long0, long1, diam=1) exo.append(enonce) cor.append(enonce) cor.append("\\par\\dotfill{}\\\\\n") @@ -260,7 +262,7 @@ def exo_reciproque_pythagore(): cor = ["\\exercice*"] while True: longueurs = couples_pythagore[random.randrange(len(couples_pythagore))] - longueurs = [longueurs[i] / 10.0 for i in range(3)] + longueurs = [old_div(longueurs[i], 10.0) for i in range(3)] if inegalite_triangulaire(longueurs): break noms = choix_points(3) @@ -330,16 +332,15 @@ def valeurs_thales(pyromax): valeurs = [0, 0, 0, 0, 0, 0, 0, 0] for i in range(3): if liste[i]: - valeurs[i] = random.randrange(15, pyromax) / 10.0 + valeurs[i] = random.randrange(15, pyromax) if liste[i + 3] and liste[i]: - valeurs[i + 3] = random.randrange(5, valeurs[i] * 10 - 9) / \ - 10.0 + valeurs[i + 3] = random.randrange(5, valeurs[i] - 9) elif liste[i + 3]: - valeurs[i + 3] = random.randrange(5, pyromax) / 10.0 + valeurs[i + 3] = random.randrange(5, pyromax) if liste[6]: - valeurs[6] = random.randrange(5, pyromax) / 10.0 + valeurs[6] = random.randrange(5, pyromax) if liste[7]: - valeurs[7] = random.randrange(5, pyromax) / 10.0 + valeurs[7] = random.randrange(5, pyromax) #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # type_thales=valeur_alea(-1,1) # -1 si papillon, 1 si triangle @@ -355,15 +356,11 @@ def valeurs_thales(pyromax): def test_valeurs_thales(valeurs, rapport, type_thales): v = [valeurs[i] for i in range(8)] if rapport[0] // 3 == 0 and rapport[1] // 3 == 2: # On donne AB et EB - v[rapport[0] + 3] = (v[rapport[0]] - v[rapport[1]]) * \ - type_thales - elif rapport[0] // 3 == 1 and rapport[1] // 3 == 2: - - # On donne AE et EB - + v[rapport[0] + 3] = (v[rapport[0]] - v[rapport[1]]) * type_thales + elif rapport[0] // 3 == 1 and rapport[1] // 3 == 2: # On donne AE et EB v[rapport[0] - 3] = v[rapport[0]] * type_thales + v[rapport[1]] if v[rapport[0] % 3]: # rapport est AE/AB - rapp = (v[rapport[0] % 3 + 3] * 1.0) / v[rapport[0] % 3] + rapp = Fraction(v[rapport[0] % 3 + 3], v[rapport[0] % 3]) else: rapp = 0 for i in range(3): @@ -371,8 +368,7 @@ def test_valeurs_thales(valeurs, rapport, type_thales): v[i] = v[i + 3] / rapp elif not v[i + 3]: v[i + 3] = v[i] * rapp - if inegalite_triangulaire(v[0:3]) and inegalite_triangulaire(v[3:6]) and \ - .3 < rapp < .7: + if inegalite_triangulaire(v[0:3]) and inegalite_triangulaire(v[3:6]) and .3 < rapp < .7: return v else: return 0 @@ -380,12 +376,12 @@ def test_valeurs_thales(valeurs, rapport, type_thales): def inegalite_triangulaire(a): # renvoie 1 si c'est un triangle, 0 sinon vrai = 0 - coef = 1.2 # evite les triangles trop ecrases + coef = Fraction(12,10) # evite les triangles trop ecrases if a[0] > a[1] and a[0] > a[2]: if a[1] + a[2] > coef * a[0]: vrai = 1 elif a[1] > a[0] and a[1] > a[2]: - if a[0] + a[2] > coef * a[1]: + if a[1] + a[2] > coef * a[1]: vrai = 1 elif a[2] > a[0] and a[2] > a[1]: if a[0] + a[1] > coef * a[2]: @@ -524,8 +520,7 @@ def tex_resolution_thales1(n, v): donnees = (creer_noms(n, r + 3), creer_noms(n, r + 6), '-', creer_noms(n, r), nombre(v[r + 3])) if donnees: - return '\\vspace{1ex}\\par De plus $%s=%s%s%s=\\unit[%s]{cm}$\n' % \ - donnees + return '\\vspace{1ex}\\par De plus $%s=%s%s%s=\\unit[%s]{cm}$\n' % donnees else: return '' @@ -570,19 +565,14 @@ def tex_resolution_thales3(n, v, arrondi): donnees = [] for i in range(3): if i != r: - donnees.extend([nom_ou_valeur(n, v, r), nom_ou_valeur(n, v, - r + 3), nom_ou_valeur(n, v, i), nom_ou_valeur(n, - v, i + 3)]) + donnees.extend([nom_ou_valeur(n, v, r), nom_ou_valeur(n, v, r + 3), nom_ou_valeur(n, v, i), + nom_ou_valeur(n, v, i + 3)]) if v[i]: # on cherche i+3 - donnees.extend([creer_noms(n, i + 3), nombre(v[i]), - nombre(v[r + 3]), nombre(v[r]), - valeur_exacte(((v[i] * 1.0) * v[r + 3]) / - v[r], approx=arrondi)]) + donnees.extend([creer_noms(n, i + 3), nombre(v[i]), nombre(v[r + 3]), nombre(v[r]), + valeur_exacte(v[i] * v[r + 3] / v[r], approx=arrondi)]) else: - donnees.extend([creer_noms(n, i), nombre(v[i + 3]), - nombre(v[r]), nombre(v[r + 3]), - valeur_exacte(((v[r] * 1.0) * v[i + 3]) / - v[r + 3], approx=arrondi)]) + donnees.extend([creer_noms(n, i), nombre(v[i + 3]), nombre(v[r]), nombre(v[r + 3]), + valeur_exacte(v[r] * v[i + 3] / v[r + 3], approx=arrondi)]) texte = \ '$\\cfrac{%s}{%s}=\\cfrac{%s}{%s}\\quad$ donc $\\quad \\boxed{%s=\\cfrac{%s\\times %s}{%s}%s}$\\par\n ' % tuple(donnees[0:9]) texte = texte + \ @@ -609,19 +599,18 @@ def tex_resolution_thales3(n, v, arrondi): def fig_thales(noms, valeurs): v = test_valeurs_thales(valeurs[0:8], valeurs[8][0], valeurs[8][1]) type_thales = valeurs[8][1] - angle = int(((100.0 * acos(((v[0] ** 2 + v[1] ** 2) - v[2] ** 2) / ((2 * - v[0]) * v[1]))) * 180) / pi) / 100.0 - v = [int(v[i] * 100) / 100.0 for i in range(8)] - mini_x = int(100.0 * min(0, v[1] * cos((angle * pi) / 180), v[3] * - type_thales, (v[4] * cos((angle * pi) / 180)) * - type_thales)) / 100.0 - 1.5 - mini_y = int(100.0 * min(0, (v[4] * sin((angle * pi) / 180)) * - type_thales)) / 100.0 - 1.5 - maxi_x = int(100.0 * max(v[0], v[1] * cos((angle * pi) / 180))) / \ - 100.0 + 1.5 - maxi_y = int((100.0 * v[1]) * sin((angle * pi) / 180)) / 100.0 + .5 - echelle = int(400 / max(abs(mini_x) + maxi_x, abs(mini_y) + maxi_y)) / \ - 100.0 + angle = int(100 * acos((v[0] ** 2 + v[1] ** 2 - v[2] ** 2) / (2 * v[0] * v[1])) * 180 / pi) / 100 + v = [old_div(int(v[i] * 100), 100.0) for i in range(8)] + mini_x = old_div(int(100.0 * min(0, v[1] * cos(old_div((angle * pi), 180)), v[3] * + type_thales, (v[4] * cos(old_div((angle * pi), 180))) * + type_thales)), 100.0) - 1.5 + mini_y = old_div(int(100.0 * min(0, (v[4] * sin(old_div((angle * pi), 180))) * + type_thales)), 100.0) - 1.5 + maxi_x = old_div(int(100.0 * max(v[0], v[1] * cos(old_div((angle * pi), 180)))), \ + 100.0) + 1.5 + maxi_y = old_div(int((100.0 * v[1]) * sin(old_div((angle * pi), 180))), 100.0) + .5 + echelle = old_div(int(old_div(400, max(abs(mini_x) + maxi_x, abs(mini_y) + maxi_y))), \ + 100.0) if type_thales == 1: return ( echelle, @@ -784,11 +773,11 @@ def resolution_trigo(v2, l2, arrondi): cor.append('\\[ %s%s=\\cfrac{%s}{%s} \\]' % (f[0], l2[4], nombre(v2[1][1]), nombre(v2[1][2]))) if f[0] == '\\sin': - r = (asin(v2[1][1] / v2[1][2]) * 180) / pi + r = old_div((asin(old_div(v2[1][1], v2[1][2])) * 180), pi) elif f[0] == '\\cos': - r = (acos(v2[1][1] / v2[1][2]) * 180) / pi + r = old_div((acos(old_div(v2[1][1], v2[1][2])) * 180), pi) else: - r = (atan(v2[1][1] / v2[1][2]) * 180) / pi + r = old_div((atan(old_div(v2[1][1], v2[1][2])) * 180), pi) cor.append(r'\[ \boxed{%s=%s^{-1}\left(\cfrac{%s}{%s}\right) %s\degres} \]' % (l2[4], f[0], nombre(v2[1][1]), nombre(v2[1][2]), valeur_exacte(r, approx=arrondi, unit=0))) @@ -796,11 +785,11 @@ def resolution_trigo(v2, l2, arrondi): cor.append('\\[ %s%s=\\cfrac{%s}{%s} \\]' % (f[0], v2[1][3], v2[0][f[1]], nombre(v2[1][2]))) if f[0] == '\\sin': - r = sin((v2[1][3] * pi) / 180) + r = sin(old_div((v2[1][3] * pi), 180)) elif f[0] == '\\cos': - r = cos((v2[1][3] * pi) / 180) + r = cos(old_div((v2[1][3] * pi), 180)) else: - r = tan((v2[1][3] * pi) / 180) + r = tan(old_div((v2[1][3] * pi), 180)) r = r * v2[1][2] cor.append(r'\[ \boxed{%s=%s%s\times %s %s} \]' % (v2[0][f[1]], f[0], v2[1][3], nombre(v2[1][2]), @@ -809,12 +798,12 @@ def resolution_trigo(v2, l2, arrondi): cor.append('\\[ %s%s=\\cfrac{%s}{%s} \\]' % (f[0], v2[1][3], nombre(v2[1][1]), v2[0][f[2]])) if f[0] == '\\sin': - r = sin((v2[1][3] * pi) / 180) + r = sin(old_div((v2[1][3] * pi), 180)) elif f[0] == '\\cos': - r = cos((v2[1][3] * pi) / 180) + r = cos(old_div((v2[1][3] * pi), 180)) else: - r = tan((v2[1][3] * pi) / 180) - r = v2[1][1] / r + r = tan(old_div((v2[1][3] * pi), 180)) + r = old_div(v2[1][1], r) cor.append(r'\[ \boxed{%s=\cfrac{%s}{%s%s} %s} \]' % (v2[0][f[2]], nombre(v2[1][1]), f[0], v2[1][3], valeur_exacte(r, approx=arrondi))) @@ -826,7 +815,7 @@ def angle(s, n): # renvoie \\widehat{ABC} où s est la liste des 3 sommets du t def valeurs_trigo(): - l = [random.randrange(10, 121) / 10.0 for dummy in range(3)] + l = [old_div(random.randrange(10, 121), 10.0) for dummy in range(3)] l.sort() l.append(random.randrange(15, 76)) trigo = 1 @@ -846,3 +835,5 @@ def valeurs_trigo(): else: v = (v, (trigo, 0, l[0], l[3])) return v + +#TODO: utils/pyromaths-cli.py generate exo_thales:1 plante sur l'arcos (ligne 605) diff --git a/src/pyromaths/ex/quatriemes/litteral.py b/src/pyromaths/ex/quatriemes/litteral.py index 9ac88a79..d399aae8 100644 --- a/src/pyromaths/ex/quatriemes/litteral.py +++ b/src/pyromaths/ex/quatriemes/litteral.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -23,6 +23,9 @@ #---------------------------------------------------------------------- # Pyromaths : Initiation au calcul littéral #---------------------------------------------------------------------- +from __future__ import unicode_literals +from builtins import chr +from builtins import range from pyromaths.outils.Priorites3 import texify, priorites, splitting from random import randrange, shuffle diff --git a/src/pyromaths/ex/quatriemes/puissances.py b/src/pyromaths/ex/quatriemes/puissances.py index fef40d8e..4836ba9b 100644 --- a/src/pyromaths/ex/quatriemes/puissances.py +++ b/src/pyromaths/ex/quatriemes/puissances.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div from pyromaths.outils.Arithmetique import pgcd, valeur_alea from pyromaths.outils.Affichage import decimaux, tex_coef from random import choice, randrange @@ -229,7 +234,7 @@ def ecr_sc(): for dummy in range(6): a = val_sc() exp = int(floor(log10(a))) - a_sc = (a * 1.) / 10 ** exp + a_sc = old_div((a * 1.), 10 ** exp) s_a = decimaux(a, 1) s_a_sc = decimaux(a_sc, 1) if randrange(2): # forme : a=a_sc*... @@ -257,7 +262,7 @@ def ecr_sc(): def exo_puissances(): from math import floor, log10 - sd = string.maketrans('.', ',') # convertit les . en , (separateur decimal) + sd = str.maketrans('.', ',') # convertit les . en , (separateur decimal) exo = ["\\exercice", u"Calculer les expressions suivantes et donner l'écriture scientifique du résultat.", "\\begin{multicols}{2}", " \\noindent%"] @@ -270,7 +275,7 @@ def exo_puissances(): cor.append("\\[ \\thenocalcul = %s \\]" % tex_puissances_0(valeurs[i]).translate(sd)) cor.append("\\[ \\thenocalcul = %s \\]" % tex_puissances_1(valeurs[i]).translate(sd)) cor.append("\\[ \\thenocalcul = %s \\]" % tex_puissances_2(valeurs[i]).translate(sd)) - if int(floor(log10(((valeurs[i][0] * valeurs[i][1]) * 1.) / valeurs[i][2]))) != \ + if int(floor(log10(old_div(((valeurs[i][0] * valeurs[i][1]) * 1.), valeurs[i][2])))) != \ 0: cor.append("\\[ \\thenocalcul = %s \\]" % tex_puissances_3(valeurs[i]).translate(sd)) cor.append("\\[ \\boxed{\\thenocalcul = %s} \\]" % @@ -285,8 +290,8 @@ def exo_puissances(): i]).translate(sd)) cor.append("\\[ \\thenocalcul = %s \\]" % tex_puissances_2(valeurs[1 - i]).translate(sd)) - if int(floor(log10(((valeurs[1 - i][0] * valeurs[1 - i][1]) * 1.) / - valeurs[1 - i][2]))) != 0: + if int(floor(log10(old_div(((valeurs[1 - i][0] * valeurs[1 - i][1]) * 1.), + valeurs[1 - i][2])))) != 0: cor.append("\\[ \\thenocalcul = %s \\]" % tex_puissances_3(valeurs[1 - i]).translate(sd)) cor.append("\\[ \\boxed{\\thenocalcul = %s} \\]" % @@ -316,39 +321,39 @@ def tex_puissances_1(a): def tex_puissances_2(a): if isinstance(a, tuple): - if ((a[0] * a[1]) * 1.) / a[2] == (a[0] * a[1]) / a[2]: + if old_div(((a[0] * a[1]) * 1.), a[2]) == old_div((a[0] * a[1]), a[2]): if a[5] * a[6] < 0: return '\\nombre{%s} \\times 10^{%s-(%s)}' % \ - verifie_type(((a[0] * a[1]) / a[2], a[3] + a[4], a[5] * + verifie_type((old_div((a[0] * a[1]), a[2]), a[3] + a[4], a[5] * a[6])) else: - return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type(((a[0] * - a[1]) / a[2], a[3] + a[4], a[5] * a[6])) + return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type((old_div((a[0] * + a[1]), a[2]), a[3] + a[4], a[5] * a[6])) else: if a[5] * a[6] < 0: return '\\nombre{%s} \\times 10^{%s-(%s)}' % \ - verifie_type((((a[0] * a[1]) * 1.) / a[2], a[3] + a[4], + verifie_type((old_div(((a[0] * a[1]) * 1.), a[2]), a[3] + a[4], a[5] * a[6])) else: - return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type((((a[0] * - a[1]) * 1.) / a[2], a[3] + a[4], a[5] * a[6])) + return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type((old_div(((a[0] * + a[1]) * 1.), a[2]), a[3] + a[4], a[5] * a[6])) def tex_puissances_3(a): from math import floor, log10 - b = int(floor(log10(((a[0] * a[1]) * 1.) / a[2]))) + b = int(floor(log10(old_div(((a[0] * a[1]) * 1.), a[2])))) if isinstance(a, tuple) and b != 0: return '\\nombre{%s} \\times 10^{%s} \\times 10^{%s}' % \ - verifie_type(((((a[0] * a[1]) * 1.) / a[2]) / 10 ** b, b, (a[3] + + verifie_type((old_div((old_div(((a[0] * a[1]) * 1.), a[2])), 10 ** b), b, (a[3] + a[4]) - a[5] * a[6])) def tex_puissances_4(a): from math import floor, log10 - b = int(floor(log10(((a[0] * a[1]) * 1.) / a[2]))) + b = int(floor(log10(old_div(((a[0] * a[1]) * 1.), a[2])))) if isinstance(a, tuple): - return '\\nombre{%s} \\times 10^{%s}' % verifie_type(((((a[0] * - a[1]) * 1.) / a[2]) / 10 ** b, (b + a[3] + a[4]) - a[5] * + return '\\nombre{%s} \\times 10^{%s}' % verifie_type((old_div((old_div(((a[0] * + a[1]) * 1.), a[2])), 10 ** b), (b + a[3] + a[4]) - a[5] * a[6])) @@ -367,7 +372,7 @@ def valeurs_puissances(): # renvoie un tuple contenant les valeurs pour les deu (maxi, emax) = (10, 2) while True: (b1, b2) = (valeur_alea(2, maxi), valeur_alea(2, maxi)) - (b1, b2) = (b1 / pgcd(b1, b2), b2 / pgcd(b1, b2)) + (b1, b2) = (old_div(b1, pgcd(b1, b2)), old_div(b2, pgcd(b1, b2))) if b1 != 1 and b2 != 1: break while True: @@ -376,7 +381,7 @@ def valeurs_puissances(): # renvoie un tuple contenant les valeurs pour les deu emax)) n3 = ((b1 * b2) * choice((2, 4, 5, 8))) * 10 ** randrange(-emax, emax) - if int(floor(log10(((n1 * n2) * 1.) / n3))) != 0 and n1 != 1 and \ + if int(floor(log10(old_div(((n1 * n2) * 1.), n3)))) != 0 and n1 != 1 and \ n2 != 1 and n3 != 1: break (e1, e2, e3, e4) = (valeur_alea(-10, 10), valeur_alea(-10, 10), @@ -384,7 +389,7 @@ def valeurs_puissances(): # renvoie un tuple contenant les valeurs pour les deu a = verifie_type((n1, n2, n3, e1, e2, e3, e4)) while True: (b1, b2) = (valeur_alea(2, maxi), valeur_alea(2, maxi)) - (b1, b2) = (b1 / pgcd(b1, b2), b2 / pgcd(b1, b2)) + (b1, b2) = (old_div(b1, pgcd(b1, b2)), old_div(b2, pgcd(b1, b2))) if b1 != 1 and b2 != 1: break (n1, n2) = ((b1 * valeur_alea(2, maxi)) * 10 ** randrange(-emax, emax + diff --git a/src/pyromaths/ex/sixiemes/__init__.py b/src/pyromaths/ex/sixiemes/__init__.py index faabeba4..36320e8d 100644 --- a/src/pyromaths/ex/sixiemes/__init__.py +++ b/src/pyromaths/ex/sixiemes/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,5 +20,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -description = u'6.Sixième' +from __future__ import unicode_literals +description = '6.Sixième' level = description diff --git a/src/pyromaths/ex/sixiemes/aires.py b/src/pyromaths/ex/sixiemes/aires.py index fc7be3d2..9d22d9ff 100644 --- a/src/pyromaths/ex/sixiemes/aires.py +++ b/src/pyromaths/ex/sixiemes/aires.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -22,14 +22,18 @@ # import sys, os # sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import random from pyromaths.outils import Affichage def boxes(): """Crée les boites pour insérer les figures dans un environnement 36x16""" - b0x, b0y = random.randrange(5, 2 * 36 / 3 - 1), random.randrange(5, 2 * 16 / 3 + 1) - b1x, b1y = random.randrange(5, 2 * (36 - b0x) / 3 - 1), random.randrange(5, - 2 * 16 / 3 + 1) - b2x, b2y = 36 - b0x - b1x - 2, random.randrange(5, 2 * 16 / 3 + 1) + b0x, b0y = random.randrange(5, 2 * old_div(36, 3) - 1), random.randrange(5, 2 * old_div(16, 3) + 1) + b1x, b1y = random.randrange(5, 2 * old_div((36 - b0x), 3) - 1), random.randrange(5, 2 * old_div(16, 3) + 1) + b2x, b2y = 36 - b0x - b1x - 2, random.randrange(5, int(2 * old_div(16, 3) + 1)) b3x, b3y = b0x, 16 - b0y - 1 b4x, b4y = b1x, 16 - b1y - 1 b5x, b5y = b2x, 16 - b2y - 1 @@ -63,7 +67,7 @@ def parallelogramme(dim, n_fig): dimensions dim et numérote la figure avec n_fig""" base_h = random.randrange(2) if base_h: - tab = random.randrange(1, min(dim[0] / 2, dim[0] - 3)) * (-1) ** random.randrange(2) + tab = random.randrange(1, min(old_div(dim[0], 2), dim[0] - 3)) * (-1) ** random.randrange(2) if tab > 0: s0, s1, s2, s3 = (tab, 0), (dim[0], 0), (dim[0] - tab, dim[1]), (0, dim[1]) @@ -73,7 +77,7 @@ def parallelogramme(dim, n_fig): dim[1]) frame0, frame1 = s0, (dim[0] + tab, dim[1]) else: - tab = random.randrange(1, min(dim[1] / 2, dim[1] - 3)) * (-1) ** random.randrange(2) + tab = random.randrange(1, min(old_div(dim[1], 2), dim[1] - 3)) * (-1) ** random.randrange(2) if tab > 0: s0, s1, s2, s3 = (0, tab), (dim[0], 0), (dim[0], dim[1] - tab), (0, dim[1]) @@ -112,7 +116,7 @@ def triangle_rectangle(dim, n_fig): 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)) + Affichage.decimaux(old_div(aire_rectangle(dim)[1], 2.), 1)) return f, fc, s def triangle_base(dim, n_fig): @@ -139,7 +143,7 @@ def triangle_base(dim, n_fig): 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)) + Affichage.decimaux(old_div(aire_rectangle(dim)[1], 2.), 1)) return f, fc, s def triangle_qcq(dim, n_fig): @@ -180,8 +184,8 @@ def triangle_qcq(dim, n_fig): (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) + old_div(aire_rectangle(s0, s1)[1], 2.) - old_div(aire_rectangle(s0, s2)[1], 2.) - + old_div(aire_rectangle(s1, s2)[1], 2.), 1) return f, fc, s def aire_rectangle(pos1, pos2=(0, 0)): @@ -195,7 +199,7 @@ def isobarycentre(*args): nbarg = len(args) * 1. isobar = [0, 0] for i in args: - isobar = [isobar[0] + i[0] / nbarg, isobar[1] + i[1] / nbarg] + isobar = [isobar[0] + old_div(i[0], nbarg), isobar[1] + old_div(i[1], nbarg)] return tuple(isobar) def figure(): diff --git a/src/pyromaths/ex/sixiemes/angles.py b/src/pyromaths/ex/sixiemes/angles.py index c631ff86..f030b5d4 100644 --- a/src/pyromaths/ex/sixiemes/angles.py +++ b/src/pyromaths/ex/sixiemes/angles.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import chr +from builtins import range +from past.utils import old_div import math from random import randrange from pyromaths.outils import Geometrie @@ -30,8 +35,8 @@ def eq_droites(A, B): (xA, yA) = A (xB, yB) = B - a = ((yB - yA) * 1.0) / (xB - xA) - b = ((xB * yA - xA * yB) * 1.0) / (xB - xA) + a = old_div(((yB - yA) * 1.0), (xB - xA)) + b = old_div(((xB * yA - xA * yB) * 1.0), (xB - xA)) return (a, b) @@ -46,8 +51,8 @@ def inter_droites(A, B, C, D): xI = A[0] yI = A[1] else: - xI = ((b2 - b1) * 1.0) / (a1 - a2) - yI = ((a1 * b2 - a2 * b1) * 1.0) / (a1 - a2) + xI = old_div(((b2 - b1) * 1.0), (a1 - a2)) + yI = old_div(((a1 * b2 - a2 * b1) * 1.0), (a1 - a2)) return (xI, yI) @@ -58,7 +63,7 @@ def dist_pt_droite(A, B, C): (a, b) = eq_droites(A, B) (xC, yC) = C - d = (abs(a * xC - yC + b) * 1.0) / math.sqrt(a ** 2 + 1) + d = old_div((abs(a * xC - yC + b) * 1.0), math.sqrt(a ** 2 + 1)) return d @@ -80,8 +85,8 @@ def coord_projete(A, B, C): (xB, yB) = B (xC, yC) = C n = dist_points(A, B) - p = (xB - xA) / n - q = (yB - yA) / n + p = old_div((xB - xA), n) + q = old_div((yB - yA), n) s = p * (xC - xA) + q * (yC - yA) return (xA + s * p, yA + s * q) @@ -143,17 +148,17 @@ def cree_angles(nb_angles, xmax, ymax): lpoints = [] cpt = 0 # evite une boucle infinie while len(lpoints) < nb_angles and cpt < 1000: - (xA, yA) = (randrange(5, xmax * 10) / 10.0, randrange(5, ymax * - 10) / 10.0) + (xA, yA) = (old_div(randrange(5, xmax * 10), 10.0), old_div(randrange(5, ymax * + 10), 10.0)) alpha = randrange(360) # angle entre un côté et l'horizontal - if len(lpoints) < nb_angles / 2: + if len(lpoints) < old_div(nb_angles, 2): beta = randrange(90, 180) # crée un angle droit ou obtus else: beta = randrange(0, 75) + 15 # crée un angle aigu (entre 15° et 89°) - xB = xA + lg_seg * math.cos((alpha * math.pi) / 180) - yB = yA + lg_seg * math.sin((alpha * math.pi) / 180) - xC = xA + lg_seg * math.cos(((alpha + beta) * math.pi) / 180) - yC = yA + lg_seg * math.sin(((alpha + beta) * math.pi) / 180) + xB = xA + lg_seg * math.cos(old_div((alpha * math.pi), 180)) + yB = yA + lg_seg * math.sin(old_div((alpha * math.pi), 180)) + xC = xA + lg_seg * math.cos(old_div(((alpha + beta) * math.pi), 180)) + yC = yA + lg_seg * math.sin(old_div(((alpha + beta) * math.pi), 180)) (A, B, C) = ((xA, yA), (xB, yB), (xC, yC)) if xA != xB and xA != xC and .5 < xB < xmax and .5 < yB < ymax and \ .5 < xC < xmax and .5 < yC < ymax and verifie_angle(lpoints, @@ -170,7 +175,7 @@ def cree_angles(nb_angles, xmax, ymax): def PosAngle(alpha, beta): """retourne les angles pour placer les points sur la figure""" - A = (alpha + beta / 2.0 + 180) % 360 + A = (alpha + old_div(beta, 2.0) + 180) % 360 B = (alpha - 90) % 360 C = (alpha + beta + 90) % 360 return (A, B, C) @@ -299,7 +304,7 @@ def tex_place_les_points_zigzag(self, corrige=False): (self.angles_absolus[0] - 180, self.points[0][0], self.points[0][1], chr(65)) if not corrige: exo += "\\pstGeonode[PosAngle=%.2f, PointSymbol=x](%.2f, %.2f){B} " % \ - (self.angles_absolus[1] + self.angles_relatifs[1] / 2. - 180, self.points[1][0], self.points[1][1]) + (self.angles_absolus[1] + old_div(self.angles_relatifs[1], 2.) - 180, self.points[1][0], self.points[1][1]) exo += "\pstSegmentMark{A}{B}\n" x1, y1 = inter_droites(self.points[0], self.points[-1], self.points[1], self.points[-2]) if 0 < x1 < 18 and 0 < y1 < self.lg + 2: @@ -308,15 +313,15 @@ def tex_place_les_points_zigzag(self, corrige=False): x1, y1 = inter_droites(self.points[0], self.points[-2], self.points[1], self.points[-1]) cas = 1 for i in range(1, 5): - exo += "\pscircle[linecolor=Gray](%.2f, %.2f){%.1f}\n" % (x1, y1, i / 10.) + exo += "\pscircle[linecolor=Gray](%.2f, %.2f){%.1f}\n" % (x1, y1, old_div(i, 10.)) if corrige: for i in range(1, len(self.angles_relatifs)): if self.angles_absolus[i - 1] > self.angles_absolus[i]: exo += "\\pstGeonode[PosAngle=%.2f](%.2f, %.2f){%s} " % \ - (self.angles_absolus[i] - self.angles_relatifs[i] / 2. - 180, self.points[i][0], self.points[i][1], chr(i + 65)) + (self.angles_absolus[i] - old_div(self.angles_relatifs[i], 2.) - 180, self.points[i][0], self.points[i][1], chr(i + 65)) else: exo += "\\pstGeonode[PosAngle=%.2f](%.2f, %.2f){%s} " % \ - (self.angles_absolus[i] + self.angles_relatifs[i] / 2. - 180, self.points[i][0], self.points[i][1], chr(i + 65)) + (self.angles_absolus[i] + old_div(self.angles_relatifs[i], 2.) - 180, self.points[i][0], self.points[i][1], chr(i + 65)) exo += "\pstSegmentMark{%s}{%s}\n" % (chr(i + 64), chr(i + 65)) exo += "\\pstGeonode[PosAngle=%.2f, PointSymbol=x](%.2f, %.2f){%s} " % \ diff --git a/src/pyromaths/ex/sixiemes/arrondi.py b/src/pyromaths/ex/sixiemes/arrondi.py index a342e538..ae335e24 100644 --- a/src/pyromaths/ex/sixiemes/arrondi.py +++ b/src/pyromaths/ex/sixiemes/arrondi.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div from random import randint, shuffle import textwrap @@ -49,10 +53,10 @@ def __init__(self): # Valeur approchée par défaut  # Arrondi = la « meilleure » valeur approchée # et ne paraît employé ici correctement - self.nombres = [(hasard[0]) / (10 ** (-self.choix_precision[0] + 4)), - (hasard[1]) / (10 ** (-self.choix_precision[1] + 4)), - (hasard[2]) / (10 ** (-self.choix_precision[2] + 4)), - (hasard[3]) / (10 ** (-self.choix_precision[3] + 4))] + self.nombres = [old_div((hasard[0]), (10 ** (-self.choix_precision[0] + 4))), + old_div((hasard[1]), (10 ** (-self.choix_precision[1] + 4))), + old_div((hasard[2]), (10 ** (-self.choix_precision[2] + 4))), + old_div((hasard[3]), (10 ** (-self.choix_precision[3] + 4)))] def tex_statement(self): exo = ["\\exercice", '\\begin{enumerate}'] diff --git a/src/pyromaths/ex/sixiemes/decimaux.py b/src/pyromaths/ex/sixiemes/decimaux.py index ae56894f..a29834cd 100644 --- a/src/pyromaths/ex/sixiemes/decimaux.py +++ b/src/pyromaths/ex/sixiemes/decimaux.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,12 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div +from decimal import Decimal import random from pyromaths.outils import Affichage, Arithmetique #=============================================================================== @@ -163,7 +169,7 @@ def NombreEnLettres(n, France=True): def nombreATrouver(): """a contient la liste des nombres à créer où il peut ne pas y avoir de centaines, de centaines de milliers, d'unités ou de milliers""" - + from decimal import Decimal a = [random.randrange(100) + random.randrange(1000) * 10 ** 3, random.randrange(1000) + random.randrange(100) * 10 ** 3, random.randrange(1000) * 10 ** 3, random.randrange(1000)] @@ -174,10 +180,10 @@ def nombreATrouver(): n = a[i] if n % 1000: # il y a des unités dans le nombre e = random.randrange(1, 4) - lnb.append(n * 10 ** (-e)) + lnb.append(n / Decimal(10 ** (e))) else: e = random.randrange(4, 7) - lnb.append(n * 10 ** (-e)) + lnb.append(n / Decimal(10 ** (e))) for i in range(8): liste.append(lnb.pop(random.randrange(len(lnb)))) return liste @@ -205,8 +211,7 @@ def EcritNombreDecimal(n): txt = txt + u' unité et ' if e > 1: txt = txt + u' unités et ' - txt = txt + NombreEnLettres(d) + partieDec[len(str(n).split('.')[1]) - - 1] + txt = txt + NombreEnLettres(d) + partieDec[len(str(n).split('.')[1]) - 1] if d > 1: txt = txt + 's' return txt @@ -330,8 +335,8 @@ def tex_units(): 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), + nb0 = Affichage.decimaux(a * Decimal(10) ** p, 0) + nb1 = Affichage.decimaux(a * Decimal(10) ** ((p + div1) - div0), 0) exo.append("\\item %s~%s%s=\dotfill~%s%s" % (nb0, division[div0], units[unit], division[div1], units[unit])) @@ -470,8 +475,8 @@ def tex_conversion(exo, cor, exposant, u): 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)) + nb0 = a * Decimal(10) ** p + nb1 = nb0 * Decimal(10) ** (exposant * (div1 - div0)) exo.append("\\item $\\unit[%s]{%s}=\\unit[\\dotfill]{%s}$" % (Affichage.decimaux(nb0), u[div0], u[div1])) @@ -498,11 +503,11 @@ def nbre_to_dict(nbre , div0, div1, exposant): nb_dict[i] = "\\textcolor{red}{0}" curseur = 1 + exposant * (div0 + 1) while nbre % 10 == 0: - nbre = nbre / 10 + nbre = old_div(nbre, 10) curseur -= 1 while nbre > 0: chiffre = nbre % 10 - nbre = (nbre - chiffre) / 10 + nbre = old_div((nbre - chiffre), 10) nb_dict[curseur] = "\\textcolor{blue}{%s}" % chiffre curseur -= 1 return nb_dict @@ -611,28 +616,28 @@ def choix_trou_frac(exo, cor, n1, p1): p2 = random.randrange(2) # sert à compliquer un peu l'exercice if i > 1: exo.append('\\item $\\cfrac{%s}{%s}=\\ldots$' % - (Affichage.decimaux(n1 * 10 ** p2), - Affichage.decimaux(10 ** (p1 + p2)))) + (Affichage.decimaux(n1 * Decimal(10) ** p2), + Affichage.decimaux(Decimal(10) ** (p1 + p2)))) cor.append('\\item $\\cfrac{%s}{%s}=\\mathbf{%s}$' % - (Affichage.decimaux(n1 * 10 ** p2), - Affichage.decimaux(10 ** (p1 + p2)), - Affichage.decimaux(n1 * 10 ** (-p1), 1))) + (Affichage.decimaux(n1 * Decimal(10) ** p2), + Affichage.decimaux(Decimal(10) ** (p1 + p2)), + Affichage.decimaux(n1 * Decimal(10) ** (-p1), 1))) elif i > 0: exo.append('\\item $\\cfrac{%s}{\ldots}=%s$' % - (Affichage.decimaux(n1 * 10 ** p2), - Affichage.decimaux(n1 * 10 ** (-p1), 1))) + (Affichage.decimaux(n1 * Decimal(10) ** p2), + Affichage.decimaux(n1 * Decimal(10) ** (-p1), 1))) cor.append('\\item $\\cfrac{%s}{\\mathbf{%s}}=%s$' % - (Affichage.decimaux(n1 * 10 ** p2), - Affichage.decimaux(10 ** (p1 + p2)), \ - Affichage.decimaux(n1 * 10 ** (-p1), 1))) + (Affichage.decimaux(n1 * Decimal(10) ** p2), + Affichage.decimaux(Decimal(10) ** (p1 + p2)), \ + Affichage.decimaux(n1 * Decimal(10) ** (-p1), 1))) else: exo.append('\\item $\\cfrac{\ldots}{%s}=%s$' % - (Affichage.decimaux(10 ** (p1 + p2)), - Affichage.decimaux(n1 * 10 ** (-p1), 1))) + (Affichage.decimaux(Decimal(10) ** (p1 + p2)), + Affichage.decimaux(n1 * Decimal(10) ** (-p1), 1))) cor.append('\\item $\\cfrac{\\mathbf{%s}}{%s}=%s$' % - (Affichage.decimaux(n1 * 10 ** p2), - Affichage.decimaux(10 ** (p1 + p2)), - Affichage.decimaux(n1 * 10 ** (-p1), 1))) + (Affichage.decimaux(n1 * Decimal(10) ** p2), + Affichage.decimaux(Decimal(10) ** (p1 + p2)), + Affichage.decimaux(n1 * Decimal(10) ** (-p1), 1))) def tex_frac(exo, cor): for dummy in range(6): @@ -735,9 +740,9 @@ def choix_nombres(): for j in range(i + 1): n = n + random.randrange(1, 10) * 10 ** (-(j + 1)) nb.append(n) - n = random.randrange(10) + random.randrange(10) / 10.0 + n = random.randrange(10) + old_div(random.randrange(10), 10.0) while n == nb[0]: - n = random.randrange(10) + random.randrange(10) / 10.0 + n = random.randrange(10) + old_div(random.randrange(10), 10.0) nb.append(n) return nb diff --git a/src/pyromaths/ex/sixiemes/droites.py b/src/pyromaths/ex/sixiemes/droites.py index 1c6640e3..a849a929 100644 --- a/src/pyromaths/ex/sixiemes/droites.py +++ b/src/pyromaths/ex/sixiemes/droites.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import chr +from builtins import range +from past.utils import old_div import random import math @@ -152,9 +157,9 @@ def tex_figure(liste, lpoints, points_coord, nodesep=0): def coord_points(lpoints): """Définit les ordonnées de trois points nommés dont les noms sont dans lpoints""" - ordonnees = [random.randrange(5, 16) / 10.for i in range(3)] + ordonnees = [old_div(random.randrange(5, 16), 10.)for i in range(3)] while abs(2 * ordonnees[1] - ordonnees[0] - ordonnees[2]) < .5: - ordonnees = [random.randrange(5, 16) / 10.for i in range(3)] + ordonnees = [old_div(random.randrange(5, 16), 10.)for i in range(3)] random.shuffle(ordonnees) for i in range(3): ordonnees.insert(2 * i + 1, lpoints[i]) @@ -269,12 +274,12 @@ def noms_sommets(nb): # renvoie nb noms de sommets def cree_coordonnees(longueur=3): from math import floor alpha = random.randrange(180) - k0 = random.randrange(50, 100) / 100.0 + k0 = old_div(random.randrange(50, 100), 100.0) a0 = alpha + random.randrange(30, 120) - k1 = random.randrange(50, 100) / 100.0 + k1 = old_div(random.randrange(50, 100), 100.0) a1 = alpha + random.randrange(210, 300) - return (longueur,alpha, longueur, alpha + 180, floor((k0* 10) * longueur) / - 10.0, a0, floor((k1 * 10) * longueur) / 10.0, a1) + return (longueur,alpha, longueur, alpha + 180, old_div(floor((k0* 10) * longueur), + 10.0), a0, old_div(floor((k1 * 10) * longueur), 10.0), a1) def enonce_perp(exo, cor): @@ -349,54 +354,54 @@ def fonction(angle, xa, ya, dist=0, droite='par'): @param droite: 'par' pour une parallèle et 'per' pour une perpendiculaire """ - angle_rad = (angle * math.pi) / 180 + angle_rad = old_div((angle * math.pi), 180) if droite == 'par': - coef = math.floor(math.tan(angle_rad) * 1000) / 1000.0 - ord_or = math.floor(((ya - xa * math.tan(angle_rad)) - dist / - math.cos(angle_rad)) * 1000) / 1000.0 + coef = old_div(math.floor(math.tan(angle_rad) * 1000), 1000.0) + ord_or = old_div(math.floor(((ya - xa * math.tan(angle_rad)) - old_div(dist, + math.cos(angle_rad))) * 1000), 1000.0) return '{x %s mul %s add}' % (coef, ord_or) else: - coef = math.floor(-1000 / math.tan(angle_rad)) / 1000.0 + coef = old_div(math.floor(old_div(-1000, math.tan(angle_rad))), 1000.0) return '{x %s mul}' % coef def PointInter(angle, xa, ya, dist=0): - angle_rad = (angle * math.pi) / 180 - coef1 = math.floor(math.tan(angle_rad) * 1000) / 1000.0 - ord_or1 = math.floor(((ya - xa * math.tan(angle_rad)) - dist / math.cos(angle_rad)) * - 1000) / 1000.0 - coef2 = math.floor(-1000 / math.tan(angle_rad)) / 1000.0 - x = ord_or1 / (coef2 - coef1) + angle_rad = old_div((angle * math.pi), 180) + coef1 = old_div(math.floor(math.tan(angle_rad) * 1000), 1000.0) + ord_or1 = old_div(math.floor(((ya - xa * math.tan(angle_rad)) - old_div(dist, math.cos(angle_rad))) * + 1000), 1000.0) + coef2 = old_div(math.floor(old_div(-1000, math.tan(angle_rad))), 1000.0) + x = old_div(ord_or1, (coef2 - coef1)) y = x * coef2 - return ',PosAngle=%s](%s,%s)' % (45 + angle, math.floor(x * 1000) / - 1000.0, math.floor(y * 1000) / 1000.0) + return ',PosAngle=%s](%s,%s)' % (45 + angle, old_div(math.floor(x * 1000), + 1000.0), old_div(math.floor(y * 1000), 1000.0)) def Points(angle, xa, ya, dist=0): - angle_rad = (angle * math.pi) / 180 - coef = math.floor(math.tan(angle_rad) * 1000) / 1000.0 - ord_or = math.floor(((ya - xa * math.tan(angle_rad)) - dist / math.cos(angle_rad)) * - 1000) / 1000.0 + angle_rad = old_div((angle * math.pi), 180) + coef = old_div(math.floor(math.tan(angle_rad) * 1000), 1000.0) + ord_or = old_div(math.floor(((ya - xa * math.tan(angle_rad)) - old_div(dist, math.cos(angle_rad))) * + 1000), 1000.0) lpos = [] if -1.5 < -2 * coef + ord_or < 1.5: x = -1.5 - y = math.floor((x * coef + ord_or) * 1000) / 1000.0 + y = old_div(math.floor((x * coef + ord_or) * 1000), 1000.0) lpos.append('(%s,%s)' % (x, y)) if -1.5 < 2 * coef + ord_or < 1.5: x = 1.5 - y = math.floor((x * coef + ord_or) * 1000) / 1000.0 + y = old_div(math.floor((x * coef + ord_or) * 1000), 1000.0) lpos.append('(%s,%s)' % (x, y)) - if -2.1 < (1.5 - ya + dist / math.cos(angle_rad) + xa * math.tan(angle_rad)) / \ - math.tan(angle_rad) < 2.1: + if -2.1 < old_div((1.5 - ya + old_div(dist, math.cos(angle_rad)) + xa * math.tan(angle_rad)), \ + math.tan(angle_rad)) < 2.1: y = 1.1 - x = math.floor(((y - ya + dist / math.cos(angle_rad) + xa * math.tan(angle_rad)) / - math.tan(angle_rad)) * 1000) / 1000.0 + x = old_div(math.floor((old_div((y - ya + old_div(dist, math.cos(angle_rad)) + xa * math.tan(angle_rad)), + math.tan(angle_rad))) * 1000), 1000.0) lpos.append('(%s,%s)' % (x, y)) - if -2.1 < (-1.5 - ya + dist / math.cos(angle_rad) + xa * math.tan(angle_rad)) / \ - math.tan(angle_rad) < 2.1: + if -2.1 < old_div((-1.5 - ya + old_div(dist, math.cos(angle_rad)) + xa * math.tan(angle_rad)), \ + math.tan(angle_rad)) < 2.1: y = -1.1 - x = math.floor(((y - ya + dist / math.cos(angle_rad) + xa * math.tan(angle_rad)) / - math.tan(angle_rad)) * 1000) / 1000.0 + x = old_div(math.floor((old_div((y - ya + old_div(dist, math.cos(angle_rad)) + xa * math.tan(angle_rad)), + math.tan(angle_rad))) * 1000), 1000.0) lpos.append('(%s,%s)' % (x, y)) return lpos @@ -454,11 +459,11 @@ def figure(angle, xa, ya, dist, lpoints, noms, par_per, dist2=0): (angle + 45, lpoints[0], lpoints[1], pts[0], pts[1])) pts = Points(angle, xa, ya, dist) ltxt.append('\\pstGeonode[PointSymbol=x,PosAngle=%s,PointName={%s,%s}]%s{b1}%s{b2}' % - (angle - (45.0 * dist) / abs(dist), lpoints[2], + (angle - old_div((45.0 * dist), abs(dist)), lpoints[2], lpoints[3], pts[0], pts[1])) pts = Points(angle, xa, ya, dist2) ltxt.append('\\pstGeonode[PointSymbol=x,PosAngle=%s,PointName={%s,%s}]%s{c1}%s{c2}' % - (angle - (45.0 * dist2) / abs(dist2), lpoints[4], + (angle - old_div((45.0 * dist2), abs(dist2)), lpoints[4], lpoints[5], pts[0], pts[1])) else: @@ -480,12 +485,12 @@ def figure(angle, xa, ya, dist, lpoints, noms, par_per, dist2=0): (angle + 45, lpoints[0], pts[0], pts[1])) pts = Points(angle, xa, ya, dist) ltxt.append('\\pstGeonode[PointSymbol=none,PosAngle=%s,PointName={%s,none}]%s{b1}%s{b2}' % - (angle - (45.0 * dist) / abs(dist), lpoints[1], + (angle - old_div((45.0 * dist), abs(dist)), lpoints[1], pts[0], pts[1])) # FIXME list index out of range pts = Points(angle, xa, ya, dist2) ltxt.append('\\pstGeonode[PointSymbol=none,PosAngle=%s,PointName={%s,none}]%s{c1}%s{c2}' % - (angle - (45.0 * dist2) / abs(dist2), lpoints[2], + (angle - old_div((45.0 * dist2), abs(dist2)), lpoints[2], pts[0], pts[1])) if par_per != 2: if angle < 90: @@ -511,17 +516,17 @@ def valeurs_figures(par_per): for dummy in range(3): lpoints.append('(d_%s)' % lindices.pop(random.randrange(len(lindices)))) angle = random.randrange(1, 90) + 90 * random.randrange(2) - xa = random.randrange(-5, 5) / 10.0 - ya = random.randrange(-3, 3) / 10.0 + xa = old_div(random.randrange(-5, 5), 10.0) + ya = old_div(random.randrange(-3, 3), 10.0) if random.randrange(2): - dist = random.randrange(4, 9) / 10.0 + dist = old_div(random.randrange(4, 9), 10.0) else: - dist = -random.randrange(4, 9) / 10.0 + dist = old_div(-random.randrange(4, 9), 10.0) if par_per == 2: if dist > 0: - dist2 = -random.randrange(4, 9) / 10.0 + dist2 = old_div(-random.randrange(4, 9), 10.0) else: - dist2 = random.randrange(4, 9) / 10.0 + dist2 = old_div(random.randrange(4, 9), 10.0) return (angle, xa, ya, dist, lpoints, noms, dist2) else: return (angle, xa, ya, dist, lpoints, noms) diff --git a/src/pyromaths/ex/sixiemes/espace.py b/src/pyromaths/ex/sixiemes/espace.py index a4792497..a603959d 100644 --- a/src/pyromaths/ex/sixiemes/espace.py +++ b/src/pyromaths/ex/sixiemes/espace.py @@ -1,4 +1,5 @@ - +from __future__ import unicode_literals + # Pyromaths # -*- coding: utf-8 -*- # @@ -21,6 +22,9 @@ # along with this program; if notPopen, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +from builtins import str +from builtins import chr +from builtins import range import random # from pyromaths.outils.Affichage import decimaux @@ -92,11 +96,11 @@ def reponse2(pt1, ptc1, F1, F2): rep = [] connects = connect(pt1, F1, F2) for pt in connects: - if pt <> ptc1: + if pt != ptc1: rep.append('[' + pt1 + pt + ']') connects2 = connect(ptc1, F1, F2) for pt in connects2: - if pt <> pt1: + if pt != pt1: rep.append('[' + ptc1 + pt + ']') rep.append('[' + pt1 + ptc1 + ']') return tuple(rep) diff --git a/src/pyromaths/ex/sixiemes/fractions.py b/src/pyromaths/ex/sixiemes/fractions.py index 4e361abe..4b318049 100644 --- a/src/pyromaths/ex/sixiemes/fractions.py +++ b/src/pyromaths/ex/sixiemes/fractions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,9 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import chr +from builtins import range import random import math diff --git a/src/pyromaths/ex/sixiemes/operations.py b/src/pyromaths/ex/sixiemes/operations.py index 8046c047..48d016b6 100644 --- a/src/pyromaths/ex/sixiemes/operations.py +++ b/src/pyromaths/ex/sixiemes/operations.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import math import random from pyromaths.outils import Arithmetique, Affichage @@ -416,22 +421,22 @@ def tex_formule_dix(l, exo, cor): (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))) + 1), Affichage.decimaux(l[1], 1), Affichage.decimaux(old_div(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))) + (Affichage.decimaux(l[0], 1), Affichage.decimaux(old_div(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))) + 1), Affichage.decimaux(l[1], 1), Affichage.decimaux(old_div(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))) + (Affichage.decimaux(l[1], 1), Affichage.decimaux(old_div(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))) + 1), Affichage.decimaux(l[1], 1), Affichage.decimaux(old_div(l[0], + l[1]), 1))) def valeurs10(nb): # renvoie nb valeur de chaque type : *10, /10, *0.1 diff --git a/src/pyromaths/ex/sixiemes/quotients.py b/src/pyromaths/ex/sixiemes/quotients.py index ff197343..c934c0ff 100644 --- a/src/pyromaths/ex/sixiemes/quotients.py +++ b/src/pyromaths/ex/sixiemes/quotients.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import range import random diff --git a/src/pyromaths/ex/sixiemes/symetrie.py b/src/pyromaths/ex/sixiemes/symetrie.py index 30426f96..4b99f859 100644 --- a/src/pyromaths/ex/sixiemes/symetrie.py +++ b/src/pyromaths/ex/sixiemes/symetrie.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import chr +from builtins import range +from past.utils import old_div import random from math import atan, cos, pi, sin @@ -32,27 +37,27 @@ def valeurs_quad2(nb_pts): vals = [] for i in range(nb_pts): - angle = random.randrange((i * 360) / nb_pts, ((i + 1) * 360) / - nb_pts) - vals.append(((random.randrange(1, 7) * .5) * cos((angle * pi) / - 180), (random.randrange(1, 7) * .5) * sin((angle * - pi) / 180))) + angle = random.randrange(old_div((i * 360), nb_pts), old_div(((i + 1) * 360), + nb_pts)) + vals.append(((random.randrange(1, 7) * .5) * cos(old_div((angle * pi), + 180)), (random.randrange(1, 7) * .5) * sin(old_div((angle * + pi), 180)))) return vals def valeurs_quad(nb_pts): vals = [] for i in range(nb_pts): - (alpha, beta) = ((i * 360) / nb_pts, ((i + 1) * 360) / nb_pts) + (alpha, beta) = (old_div((i * 360), nb_pts), old_div(((i + 1) * 360), nb_pts)) (x, y, angle) = (0, 0, 0) while x == 0 or angle < alpha or angle > beta: (x, y) = (random.randrange(-6, 7) * .5, random.randrange(-6, 7) * .5) if x > 0: - angle = int((atan((y * 1.0) / x) * 180) / pi + 360) % \ + angle = int(old_div((atan(old_div((y * 1.0), x)) * 180), pi) + 360) % \ 360 if x < 0: - angle = int((atan((y * 1.0) / x) * 180) / pi + 180) + angle = int(old_div((atan(old_div((y * 1.0), x)) * 180), pi) + 180) vals.append((x, y)) return vals diff --git a/src/pyromaths/ex/test.py b/src/pyromaths/ex/test.py index 413f06a8..aa104f75 100644 --- a/src/pyromaths/ex/test.py +++ b/src/pyromaths/ex/test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (C) 2015 -- Louis Paternault (spalax@gresille.org) @@ -21,11 +21,14 @@ This module gather tests from all exercises. Running: - python -m unittest discover + python3 -m unittest discover does just as expected. """ +from __future__ import print_function +from __future__ import unicode_literals +from builtins import object import codecs import difflib import gettext @@ -38,7 +41,7 @@ import unittest # Quick and dirty definition of `_` as the identity function -gettext.install('pyromaths', unicode=1) +gettext.install('pyromaths') import pyromaths from pyromaths.outils import System @@ -233,7 +236,7 @@ def __init__(self): def iter_names(self): """Iterate over exercise names.""" - return self.exercises.keys() + return list(self.exercises.keys()) def get(self, exercise, seed): """Return the `TestExercise` object corresponding to the arguments.""" diff --git a/src/pyromaths/ex/troisiemes/__init__.py b/src/pyromaths/ex/troisiemes/__init__.py index 8f399b80..0691f220 100644 --- a/src/pyromaths/ex/troisiemes/__init__.py +++ b/src/pyromaths/ex/troisiemes/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,5 +20,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -description = u'3.Troisième' +from __future__ import unicode_literals +description = '3.Troisième' level = description diff --git a/src/pyromaths/ex/troisiemes/affine.py b/src/pyromaths/ex/troisiemes/affine.py index 07d26434..4485e65e 100644 --- a/src/pyromaths/ex/troisiemes/affine.py +++ b/src/pyromaths/ex/troisiemes/affine.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -23,6 +23,10 @@ # fonction affine 3e # from math import * +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from past.utils import old_div from math import sqrt from pyromaths.classes.Fractions import Fraction # fractions pyromaths from pyromaths.classes.PolynomesCollege import Polynome @@ -39,12 +43,12 @@ def extreme(a, b, xmin, xmax, ymin, ymax): x2 = float(b[0]) y1 = float(a[1]) y2 = float(b[1]) - coef = float((y1 - y2) / (x1 - x2)) + coef = float(old_div((y1 - y2), (x1 - x2))) if coef != 0: - xsort1 = float(x1 + (ymin - y1) / coef) # abscisse du point d'ordonnée ymin + xsort1 = float(x1 + old_div((ymin - y1), coef)) # abscisse du point d'ordonnée ymin if xsort1 >= xmin and xsort1 <= xmax and not(xsort1, ymin) in res: res.append((xsort1, ymin)) - xsort2 = float(x2 + (ymax - y2) / coef) # abscisse du point d'ordonnée ymax + xsort2 = float(x2 + old_div((ymax - y2), coef)) # abscisse du point d'ordonnée ymax if xsort2 >= xmin and xsort2 <= xmax and not(xsort2, ymax) in res: res.append((xsort2, ymax)) ysort1 = float(y1 + coef * (xmin - x1)) # ordonnée du point d'abscisse xmin @@ -60,7 +64,7 @@ def extreme(a, b, xmin, xmax, ymin, ymax): def vecdir(A, B): # retourne sous forme de liste le vecteur directeur normé de la droite (AB) norm = sqrt((B[0] - A[0]) ** 2 + (B[1] - A[1]) ** 2) - u = [(B[0] - A[0]) / norm, (B[1] - A[1]) / norm] + u = [old_div((B[0] - A[0]), norm), old_div((B[1] - A[1]), norm)] if u[0] < 0: u[0] = -u[0] u[1] = -u[1] @@ -89,7 +93,7 @@ def validec(A, B): def doublefleche(A, B): # trace une flèche "double" de justification en pointillés - mid = (float((A[0] + B[0])) / 2, float((A[1] + B[1])) / 2) + mid = (old_div(float((A[0] + B[0])), 2), old_div(float((A[1] + B[1])), 2)) res1 = "\\psline[linestyle=dashed,linewidth=1.1pt]{->}" + str(A) + str(mid) + '\n ' res2 = "\\psline[linestyle=dashed,linewidth=1.1pt]{->}" + str(mid) + str(B) res = res1 + res2 @@ -99,10 +103,10 @@ def doublefleche(A, B): return res def couple () : - A = (float(random.randrange(-8, 9)) / 2, float(random.randrange(-8, 9)) / 2) - B = (float(random.randrange(-8, 9)) / 2, float(random.randrange(-8, 9)) / 2) + A = (old_div(float(random.randrange(-8, 9)), 2), old_div(float(random.randrange(-8, 9)), 2)) + B = (old_div(float(random.randrange(-8, 9)), 2), old_div(float(random.randrange(-8, 9)), 2)) while not validec(A, B): - B = (float(random.randrange(-8, 9)) / 2, float(random.randrange(-8, 9)) / 2) + B = (old_div(float(random.randrange(-8, 9)), 2), old_div(float(random.randrange(-8, 9)), 2)) return (A, B) def coupletrace () : @@ -114,19 +118,19 @@ def coupletrace () : def couples (): # génère 6 points. Chaque couple correspondra a une droite ( (AB)(CD)(EF)). - A = (float(random.randrange(-8, 9)) / 2, float(random.randrange(-8, 9)) / 2) - B = (float(random.randrange(-8, 9)) / 2, float(random.randrange(-8, 9)) / 2) + A = (old_div(float(random.randrange(-8, 9)), 2), old_div(float(random.randrange(-8, 9)), 2)) + B = (old_div(float(random.randrange(-8, 9)), 2), old_div(float(random.randrange(-8, 9)), 2)) while not validedroite(A, B): - B = (float(random.randrange(-8, 9)) / 2, float(random.randrange(-8, 9)) / 2) + B = (old_div(float(random.randrange(-8, 9)), 2), old_div(float(random.randrange(-8, 9)), 2)) C = (0, float(random.randrange(-4, 5))) while not (validec(A, C) and validec(B, C)): C = (0, float(random.randrange(-4, 5))) D = (float(random.randrange(-4, 5)), float(random.randrange(-4, 5))) while not (validec(A, D) and validec(B, D) and validedroite(C, D)) : D = (float(random.randrange(-4, 5)), float(random.randrange(-4, 5))) - E = (0, float(random.randrange(-8, 9)) / 2) + E = (0, old_div(float(random.randrange(-8, 9)), 2)) while not (validec(A, E) and validec(B, E) and validec(C, E) and validec(D, E)): - E = (0, float(random.randrange(-8, 9)) / 2) + E = (0, old_div(float(random.randrange(-8, 9)), 2)) F = (float(random.randrange(-4, 5)), float(random.randrange(-4, 5))) while not (validec(A, F) and validec(B, F) and validec(C, F) and validec(D, F)and validedroite(E, F)): F = (float(random.randrange(-4, 5)), float(random.randrange(-4, 5))) @@ -303,15 +307,15 @@ def exprfonc(f, i, A, B): if float(B[0]) < 0 : mid11 = float(B[0]) - 0.75 - mid12 = float((B[1] + A[1])) / 2 # milieu de la flèche verticale + mid12 = old_div(float((B[1] + A[1])), 2) # milieu de la flèche verticale else: mid11 = float(B[0]) + 0.75 - mid12 = float((B[1] + A[1])) / 2 - if float(B[0]) * float(u.d / u.n) > 0 : - mid21 = float((A[0] + B[0])) / 2 + mid12 = old_div(float((B[1] + A[1])), 2) + if float(B[0]) * float(old_div(u.d, u.n)) > 0 : + mid21 = old_div(float((A[0] + B[0])), 2) mid22 = A[1] - 0.6 # milieu de la flèche horizontale else : - mid21 = float((A[0] + B[0])) / 2 + mid21 = old_div(float((A[0] + B[0])), 2) mid22 = A[1] + 0.5 if mid12 < 0 and mid12 > -0.8: mid12 = -1 diff --git a/src/pyromaths/ex/troisiemes/arithmetique.py b/src/pyromaths/ex/troisiemes/arithmetique.py index 89082c40..f1747a12 100644 --- a/src/pyromaths/ex/troisiemes/arithmetique.py +++ b/src/pyromaths/ex/troisiemes/arithmetique.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,10 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import range +from past.utils import old_div from pyromaths.outils.Arithmetique import pgcd, factoriseTex, carrerise from pyromaths.outils.Affichage import decimaux from random import randint, shuffle @@ -119,7 +123,7 @@ def Arithmetique(): temp += decimaux(fauxpgcd * pgcdcompl) + ".$\\par" cor.append(temp) - vraippcm = (listenombres[1] * listenombres[2]) / (fauxpgcd * pgcdcompl) + vraippcm = old_div((listenombres[1] * listenombres[2]), (fauxpgcd * pgcdcompl)) if (listenombres[1] % listenombres[2] == 0): cor.append(decimaux(listenombres[1]) + u" est un multiple de " + @@ -175,7 +179,7 @@ def Arithmetique(): else: temp += decimaux(factornb1[j]) - factcompl = factoriseTex(listenombres[1] / (fauxpgcd * pgcdcompl))[0] + factcompl = factoriseTex(old_div(listenombres[1], (fauxpgcd * pgcdcompl)))[0] if len(factcompl) == 1: temp += u"$ est : " @@ -253,8 +257,8 @@ def Arithmetique(): cor.append(u"$\dfrac{" + decimaux(listenombres[1]) + "{\\scriptstyle \\div " + decimaux(fauxpgcd * pgcdcompl) + "}}{" + decimaux(listenombres[2]) + "{\\scriptstyle \\div " + decimaux(fauxpgcd * pgcdcompl) + - "}} = \dfrac{" + decimaux(listenombres[1] / (fauxpgcd * pgcdcompl)) + - "}{" + decimaux(listenombres[2] / (fauxpgcd * pgcdcompl)) + "}.$") + "}} = \dfrac{" + decimaux(old_div(listenombres[1], (fauxpgcd * pgcdcompl))) + + "}{" + decimaux(old_div(listenombres[2], (fauxpgcd * pgcdcompl))) + "}.$") # ## Question 5 @@ -263,8 +267,8 @@ def Arithmetique(): decimaux(listenombres[1]) + "} + \\dfrac{" + decimaux(num[1]) + "}{" + decimaux(listenombres[2]) + "}$.") - mult1 = vraippcm / listenombres[1] - mult2 = vraippcm / listenombres[2] + mult1 = old_div(vraippcm, listenombres[1]) + mult2 = old_div(vraippcm, listenombres[2]) num1 = mult1 * num[0] num2 = mult2 * num[1] @@ -273,8 +277,8 @@ def Arithmetique(): if simplfin != 1: simpl = "{\\scriptstyle \\div " + decimaux(simplfin) + "}" - result = " = \\dfrac{" + decimaux((num1 + num2) / simplfin) + "}{" + \ - decimaux((vraippcm) / simplfin) + "}" + result = " = \\dfrac{" + decimaux(old_div((num1 + num2), simplfin)) + "}{" + \ + decimaux(old_div((vraippcm), simplfin)) + "}" else: simpl = "" result = "" diff --git a/src/pyromaths/ex/troisiemes/developpements.py b/src/pyromaths/ex/troisiemes/developpements.py index f7cd4715..a37a334c 100644 --- a/src/pyromaths/ex/troisiemes/developpements.py +++ b/src/pyromaths/ex/troisiemes/developpements.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import chr +from builtins import range from random import randrange, shuffle from pyromaths.classes.Fractions import Fraction from pyromaths.outils import Priorites3 diff --git a/src/pyromaths/ex/troisiemes/equations.py b/src/pyromaths/ex/troisiemes/equations.py index a08013db..07e188db 100644 --- a/src/pyromaths/ex/troisiemes/equations.py +++ b/src/pyromaths/ex/troisiemes/equations.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,9 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import str +from builtins import range from pyromaths.outils import Arithmetique from . import fractions from pyromaths.classes.PolynomesCollege import Polynome diff --git a/src/pyromaths/ex/troisiemes/factorisations.py b/src/pyromaths/ex/troisiemes/factorisations.py index 1187cd4f..8c02aadb 100644 --- a/src/pyromaths/ex/troisiemes/factorisations.py +++ b/src/pyromaths/ex/troisiemes/factorisations.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import chr +from builtins import range from random import randrange, shuffle from pyromaths.outils import Priorites3 from pyromaths.classes.PolynomesCollege import factoriser diff --git a/src/pyromaths/ex/troisiemes/fractions.py b/src/pyromaths/ex/troisiemes/fractions.py index b659a91f..452183e0 100644 --- a/src/pyromaths/ex/troisiemes/fractions.py +++ b/src/pyromaths/ex/troisiemes/fractions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import range from pyromaths.outils.Arithmetique import ppcm, pgcd, signe, valeur_alea from random import randrange diff --git a/src/pyromaths/ex/troisiemes/geometrie.py b/src/pyromaths/ex/troisiemes/geometrie.py index 31f13fdd..d39806b1 100644 --- a/src/pyromaths/ex/troisiemes/geometrie.py +++ b/src/pyromaths/ex/troisiemes/geometrie.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import random from math import acos, asin, atan, pi, sin, cos, tan @@ -64,16 +69,16 @@ def valeurs_thales(valeurmax, typeexo): valeurs = [0, 0, 0, 0, 0, 0, 0, 0] for i in range(3): if liste[i]: - valeurs[i] = random.randrange(15, valeurmax) / 10.0 + valeurs[i] = old_div(random.randrange(15, valeurmax), 10.0) if liste[i + 3] and liste[i]: - valeurs[i + 3] = random.randrange(5, valeurs[i] * 10 - 9) / \ - 10.0 + valeurs[i + 3] = old_div(random.randrange(5, valeurs[i] * 10 - 9), \ + 10.0) elif liste[i + 3]: - valeurs[i + 3] = random.randrange(5, valeurmax) / 10.0 + valeurs[i + 3] = old_div(random.randrange(5, valeurmax), 10.0) if liste[6]: - valeurs[6] = random.randrange(5, valeurmax) / 10.0 + valeurs[6] = old_div(random.randrange(5, valeurmax), 10.0) if liste[7]: - valeurs[7] = random.randrange(5, valeurmax) / 10.0 + valeurs[7] = old_div(random.randrange(5, valeurmax), 10.0) valeurs.append((rapport, typeexo)) if test_valeurs_thales(valeurs, rapport, typeexo): @@ -93,12 +98,12 @@ def test_valeurs_thales(valeurs, rapport, type_thales): v[rapport[0] - 3] = v[rapport[0]] * type_thales + v[rapport[1]] if v[rapport[0] % 3]: # rapport est AE/AB - rapp = (v[rapport[0] % 3 + 3] * 1.0) / v[rapport[0] % 3] + rapp = old_div((v[rapport[0] % 3 + 3] * 1.0), v[rapport[0] % 3]) else: rapp = 0 for i in range(3): if not v[i] and rapp: - v[i] = v[i + 3] / rapp + v[i] = old_div(v[i + 3], rapp) elif not v[i + 3]: v[i + 3] = v[i] * rapp if inegalite_triangulaire(v[0:3]) and inegalite_triangulaire(v[3:6]) and \ @@ -308,13 +313,13 @@ def tex_resolution_thales3(n, v, arrondi): if v[i]: # on cherche i+3 donnees.extend([creer_noms(n, i + 3), nombre(v[i]), nombre(v[r + 3]), nombre(v[r]), - valeur_exacte(((v[i] * 1.0) * v[r + 3]) / - v[r], approx=arrondi)]) + valeur_exacte(old_div(((v[i] * 1.0) * v[r + 3]), + v[r]), approx=arrondi)]) else: donnees.extend([creer_noms(n, i), nombre(v[i + 3]), nombre(v[r]), nombre(v[r + 3]), - valeur_exacte(((v[r] * 1.0) * v[i + 3]) / - v[r + 3], approx=arrondi)]) + valeur_exacte(old_div(((v[r] * 1.0) * v[i + 3]), + v[r + 3]), approx=arrondi)]) texte = \ '$\\cfrac{%s}{%s}=\\cfrac{%s}{%s}\\quad$ donc $\\boxed{%s=\\cfrac{%s\\times %s}{%s}%s}$\\hfill' % \ tuple(donnees[0:9]) @@ -328,19 +333,19 @@ def tex_resolution_thales3(n, v, arrondi): def fig_thales(noms, valeurs): v = test_valeurs_thales(valeurs[0:8], valeurs[8][0], valeurs[8][1]) type_thales = valeurs[8][1] - angle = int(((100.0 * acos(((v[0] ** 2 + v[1] ** 2) - v[2] ** 2) / ((2 * - v[0]) * v[1]))) * 180) / pi) / 100.0 - v = [int(v[i] * 100) / 100.0 for i in range(8)] - mini_x = int(100.0 * min(0, v[1] * cos((angle * pi) / 180), v[3] * - type_thales, (v[4] * cos((angle * pi) / 180)) * - type_thales)) / 100.0 - 1.5 - mini_y = int(100.0 * min(0, (v[4] * sin((angle * pi) / 180)) * - type_thales)) / 100.0 - 1.5 - maxi_x = int(100.0 * max(v[0], v[1] * cos((angle * pi) / 180))) / \ - 100.0 + 1.5 - maxi_y = int((100.0 * v[1]) * sin((angle * pi) / 180)) / 100.0 + .5 - echelle = int(400 / max(abs(mini_x) + maxi_x, abs(mini_y) + maxi_y)) / \ - 100.0 + angle = old_div(int(old_div(((100.0 * acos(old_div(((v[0] ** 2 + v[1] ** 2) - v[2] ** 2), ((2 * + v[0]) * v[1])))) * 180), pi)), 100.0) + v = [old_div(int(v[i] * 100), 100.0) for i in range(8)] + mini_x = old_div(int(100.0 * min(0, v[1] * cos(old_div((angle * pi), 180)), v[3] * + type_thales, (v[4] * cos(old_div((angle * pi), 180))) * + type_thales)), 100.0) - 1.5 + mini_y = old_div(int(100.0 * min(0, (v[4] * sin(old_div((angle * pi), 180))) * + type_thales)), 100.0) - 1.5 + maxi_x = old_div(int(100.0 * max(v[0], v[1] * cos(old_div((angle * pi), 180)))), \ + 100.0) + 1.5 + maxi_y = old_div(int((100.0 * v[1]) * sin(old_div((angle * pi), 180))), 100.0) + .5 + echelle = old_div(int(old_div(400, max(abs(mini_x) + maxi_x, abs(mini_y) + maxi_y))), \ + 100.0) if type_thales == 1: return ( echelle, @@ -420,12 +425,12 @@ def valeurs_reciproque_thales(): (a, b, c, d) = (random.randrange(2, 50), random.randrange(2, 50), random.randrange(2, 20), random.randrange(2, 20)) p1 = pgcd(a, b) - (a, b) = (a / p1, b / p1) + (a, b) = (old_div(a, p1), old_div(b, p1)) if c < d: (c, d) = (d, c) - if a != b and int(c / d) != (c * 1.0) / d and 10 < a * c < 200 and \ + if a != b and int(old_div(c, d)) != old_div((c * 1.0), d) and 10 < a * c < 200 and \ 10 < a * d < 200 and 10 < b * c < 200 and 10 < b * d < 200 and \ - .3 < (d * 1.0) / c < .7: + .3 < old_div((d * 1.0), c) < .7: break t = valeur_alea(-1, 1) # -1 si papillon, 1 si triangle r = random.randrange(5) @@ -433,14 +438,14 @@ def valeurs_reciproque_thales(): r = random.randrange(5) angle = random.randrange(15, 105) valeurs = ( - (a * c) / 10.0, - (b * c) / 10.0, + old_div((a * c), 10.0), + old_div((b * c), 10.0), 0, - (a * d) / 10.0, - (b * d) / 10.0, + old_div((a * d), 10.0), + old_div((b * d), 10.0), 0, - (a * c - (t * a) * d) / 10.0, - (b * c - (t * b) * d) / 10.0, + old_div((a * c - (t * a) * d), 10.0), + old_div((b * c - (t * b) * d), 10.0), angle, t, r, @@ -451,16 +456,16 @@ def valeurs_reciproque_thales(): def fig_rec_thales(noms, v): type_thales = v[9] angle = v[8] - mini_x = int(100.0 * min(0, v[1] * cos((angle * pi) / 180), v[3] * - type_thales, (v[4] * cos((angle * pi) / 180)) * - type_thales)) / 100.0 - 1.5 - mini_y = int(100.0 * min(0, (v[4] * sin((angle * pi) / 180)) * - type_thales)) / 100.0 - 1.5 - maxi_x = int(100.0 * max(v[0], v[1] * cos((angle * pi) / 180))) / \ - 100.0 + 1.5 - maxi_y = int((100.0 * v[1]) * sin((angle * pi) / 180)) / 100.0 + .5 - echelle = int(400 / max(abs(mini_x) + maxi_x, abs(mini_y) + maxi_y)) / \ - 100.0 + mini_x = old_div(int(100.0 * min(0, v[1] * cos(old_div((angle * pi), 180)), v[3] * + type_thales, (v[4] * cos(old_div((angle * pi), 180))) * + type_thales)), 100.0) - 1.5 + mini_y = old_div(int(100.0 * min(0, (v[4] * sin(old_div((angle * pi), 180))) * + type_thales)), 100.0) - 1.5 + maxi_x = old_div(int(100.0 * max(v[0], v[1] * cos(old_div((angle * pi), 180)))), \ + 100.0) + 1.5 + maxi_y = old_div(int((100.0 * v[1]) * sin(old_div((angle * pi), 180))), 100.0) + .5 + echelle = old_div(int(old_div(400, max(abs(mini_x) + maxi_x, abs(mini_y) + maxi_y))), \ + 100.0) if type_thales == 1: return ( echelle, @@ -604,8 +609,8 @@ def resolution_rec_thales1(n, v): for i in range(2): d.extend([creer_noms(n, i), creer_noms(n, i + 3), nombre(v[i]), nombre(v[i + 3])]) - if valeur_exacte(v[i] / v[i + 3], approx=5).count('='): - d.append(valeur_exacte(v[i] / v[i + 3], approx=5, unit=0)) + if valeur_exacte(old_div(v[i], v[i + 3]), approx=5).count('='): + d.append(valeur_exacte(old_div(v[i], v[i + 3]), approx=5, unit=0)) else: if v[i] != int(v[i]) or v[i + 3] != int(v[i + 3]): p = pgcd(int(v[i] * 10), int(v[i + 3] * 10)) @@ -733,22 +738,22 @@ def resolution_trigo(cor, v2, l2, arrondi): cor.append(u'\\[ %s%s=\\cfrac{%s}{%s}' % (f[0], l2[4], nombre(v2[1][1]), nombre(v2[1][2])) + '\\] ') if f[0] == '\\sin': - r = (asin(v2[1][1] / v2[1][2]) * 180) / pi + r = old_div((asin(old_div(v2[1][1], v2[1][2])) * 180), pi) elif f[0] == '\\cos': - r = (acos(v2[1][1] / v2[1][2]) * 180) / pi + r = old_div((acos(old_div(v2[1][1], v2[1][2])) * 180), pi) else: - r = (atan(v2[1][1] / v2[1][2]) * 180) / pi + r = old_div((atan(old_div(v2[1][1], v2[1][2])) * 180), pi) cor.append(r'\[ \boxed{%s=%s^{-1}\left(\cfrac{%s}{%s}\right) %s\degres} \]' % (l2[4], f[0], nombre(v2[1][1]), v2[1][2], valeur_exacte(r, approx=arrondi, unit=0))) elif not v2[1][1]: cor.append(u'\\[ %s%s=\\cfrac{%s}{%s}' % (f[0], v2[1][3], v2[0][f[1]], nombre(v2[1][2])) + '\\] ') if f[0] == '\\sin': - r = sin((v2[1][3] * pi) / 180) + r = sin(old_div((v2[1][3] * pi), 180)) elif f[0] == '\\cos': - r = cos((v2[1][3] * pi) / 180) + r = cos(old_div((v2[1][3] * pi), 180)) else: - r = tan((v2[1][3] * pi) / 180) + r = tan(old_div((v2[1][3] * pi), 180)) r = r * v2[1][2] cor.append(r'\[ \boxed{%s=%s%s\times %s %s } \]' % (v2[0][f[1]], f[0], v2[1][3], nombre(v2[1][2]), valeur_exacte(r, approx=arrondi))) @@ -756,12 +761,12 @@ def resolution_trigo(cor, v2, l2, arrondi): cor.append(u'\\[ %s%s=\\cfrac{%s}{%s}' % (f[0], v2[1][3], nombre(v2[1][1]), v2[0][f[2]]) + '\\] ') if f[0] == '\\sin': - r = sin((v2[1][3] * pi) / 180) + r = sin(old_div((v2[1][3] * pi), 180)) elif f[0] == '\\cos': - r = cos((v2[1][3] * pi) / 180) + r = cos(old_div((v2[1][3] * pi), 180)) else: - r = tan((v2[1][3] * pi) / 180) - r = v2[1][1] / r + r = tan(old_div((v2[1][3] * pi), 180)) + r = old_div(v2[1][1], r) cor.append(r'\[ \boxed{%s=\cfrac{%s}{%s%s} %s} \]' % (v2[0][f[2]], nombre(v2[1][1]), f[0], v2[1][3], valeur_exacte(r, approx=arrondi))) @@ -771,7 +776,7 @@ def tex_angle(s, n): # renvoie \\widehat{ABC} où s est la liste des 3 sommets def valeurs_trigo(): - l = [random.randrange(10, 121) / 10.0 for i in range(3)] + l = [old_div(random.randrange(10, 121), 10.0) for i in range(3)] l.sort() l.append(random.randrange(15, 76)) trigo = random.randrange(3) diff --git a/src/pyromaths/ex/troisiemes/notion_de_fonction.py b/src/pyromaths/ex/troisiemes/notion_de_fonction.py index fab44730..906d3433 100644 --- a/src/pyromaths/ex/troisiemes/notion_de_fonction.py +++ b/src/pyromaths/ex/troisiemes/notion_de_fonction.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -25,7 +25,10 @@ .. sectionauthor:: Jérôme Ortais ''' +from __future__ import unicode_literals +from builtins import str +from builtins import range from random import shuffle, randrange from pyromaths.classes.PolynomesCollege import Lagrange, choix_points diff --git a/src/pyromaths/ex/troisiemes/pgcd.py b/src/pyromaths/ex/troisiemes/pgcd.py index d46b8a66..bb2e3f86 100644 --- a/src/pyromaths/ex/troisiemes/pgcd.py +++ b/src/pyromaths/ex/troisiemes/pgcd.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,9 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import str +from builtins import range import random # diff --git a/src/pyromaths/ex/troisiemes/proba.py b/src/pyromaths/ex/troisiemes/proba.py index 0fa8f862..1d41db49 100644 --- a/src/pyromaths/ex/troisiemes/proba.py +++ b/src/pyromaths/ex/troisiemes/proba.py @@ -20,6 +20,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import str import random from pyromaths.classes.Fractions import Fraction diff --git a/src/pyromaths/ex/troisiemes/proportionnalite.py b/src/pyromaths/ex/troisiemes/proportionnalite.py index 6ef263b2..a129c52c 100644 --- a/src/pyromaths/ex/troisiemes/proportionnalite.py +++ b/src/pyromaths/ex/troisiemes/proportionnalite.py @@ -19,6 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from past.utils import old_div from random import randint, shuffle, randrange from pyromaths.outils.decimaux import decimaux # from pyromaths.outils.Geometrie import cotation, cotation_h @@ -30,10 +33,10 @@ def choix_valeurs(min_prct, max_prct, min_nbre, max_nbre): shuffle(decomp100) prct = decomp100[0] * decomp100[1] * decomp100[2] # qui donne 2, 4, 5, 10, 20, 25 ou 50 tot = decomp100[3] * decomp100[4] * decomp100[5] - if (max_prct / prct != 0) and (max_nbre / tot != 0): + if (old_div(max_prct, prct) != 0) and (old_div(max_nbre, tot) != 0): break - prct = randint(max(min_prct / prct, 1), (max_prct / prct)) * prct - tot = tot * randint(max(min_nbre / tot, 1) , (max_nbre / tot)) + prct = randint(max(old_div(min_prct, prct), 1), (old_div(max_prct, prct))) * prct + tot = tot * randint(max(old_div(min_nbre, tot), 1) , (old_div(max_nbre, tot))) return prct, tot def proportionnalite_3eme(): diff --git a/src/pyromaths/ex/troisiemes/puissances.py b/src/pyromaths/ex/troisiemes/puissances.py index 46ebade6..0abd2262 100644 --- a/src/pyromaths/ex/troisiemes/puissances.py +++ b/src/pyromaths/ex/troisiemes/puissances.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div from pyromaths.outils.Arithmetique import pgcd, valeur_alea from random import choice, randrange import string, math @@ -46,39 +51,39 @@ def tex_puissances_1(a): def tex_puissances_2(a): if isinstance(a, tuple): - if ((a[0] * a[1]) * 1.) / a[2] == (a[0] * a[1]) / a[2]: + if old_div(((a[0] * a[1]) * 1.), a[2]) == old_div((a[0] * a[1]), a[2]): if a[5] * a[6] < 0: return '\\nombre{%s} \\times 10^{%s-(%s)}' % \ - verifie_type(((a[0] * a[1]) / a[2], a[3] + a[4], a[5] * + verifie_type((old_div((a[0] * a[1]), a[2]), a[3] + a[4], a[5] * a[6])) else: - return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type(((a[0] * - a[1]) / a[2], a[3] + a[4], a[5] * a[6])) + return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type((old_div((a[0] * + a[1]), a[2]), a[3] + a[4], a[5] * a[6])) else: if a[5] * a[6] < 0: return '\\nombre{%s} \\times 10^{%s-(%s)}' % \ - verifie_type((((a[0] * a[1]) * 1.) / a[2], a[3] + a[4], + verifie_type((old_div(((a[0] * a[1]) * 1.), a[2]), a[3] + a[4], a[5] * a[6])) else: - return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type((((a[0] * - a[1]) * 1.) / a[2], a[3] + a[4], a[5] * a[6])) + return '\\nombre{%s} \\times 10^{%s-%s}' % verifie_type((old_div(((a[0] * + a[1]) * 1.), a[2]), a[3] + a[4], a[5] * a[6])) def tex_puissances_3(a): from math import floor, log10 - b = int(floor(log10(((a[0] * a[1]) * 1.) / a[2]))) + b = int(floor(log10(old_div(((a[0] * a[1]) * 1.), a[2])))) if isinstance(a, tuple) and b != 0: return '\\nombre{%s} \\times 10^{%s} \\times 10^{%s}' % \ - verifie_type(((((a[0] * a[1]) * 1.) / a[2]) / 10 ** b, b, (a[3] + + verifie_type((old_div((old_div(((a[0] * a[1]) * 1.), a[2])), 10 ** b), b, (a[3] + a[4]) - a[5] * a[6])) def tex_puissances_4(a): from math import floor, log10 - b = int(floor(log10(((a[0] * a[1]) * 1.) / a[2]))) + b = int(floor(log10(old_div(((a[0] * a[1]) * 1.), a[2])))) if isinstance(a, tuple): - return '\\nombre{%s} \\times 10^{%s}' % verifie_type(((((a[0] * - a[1]) * 1.) / a[2]) / 10 ** b, (b + a[3] + a[4]) - a[5] * + return '\\nombre{%s} \\times 10^{%s}' % verifie_type((old_div((old_div(((a[0] * + a[1]) * 1.), a[2])), 10 ** b), (b + a[3] + a[4]) - a[5] * a[6])) @@ -97,7 +102,7 @@ def valeurs_puissances(): # renvoie un tuple contenant les valeurs pour les deu (maxi, emax) = (10, 2) while True: (b1, b2) = (valeur_alea(2, maxi), valeur_alea(2, maxi)) - (b1, b2) = (b1 / pgcd(b1, b2), b2 / pgcd(b1, b2)) + (b1, b2) = (old_div(b1, pgcd(b1, b2)), old_div(b2, pgcd(b1, b2))) if b1 != 1 and b2 != 1: break while True: @@ -106,7 +111,7 @@ def valeurs_puissances(): # renvoie un tuple contenant les valeurs pour les deu emax)) n3 = ((b1 * b2) * choice((2, 4, 5, 8))) * 10 ** randrange(-emax, emax) - if int(floor(log10(((n1 * n2) * 1.) / n3))) != 0 and n1 != 1 and \ + if int(floor(log10(old_div(((n1 * n2) * 1.), n3)))) != 0 and n1 != 1 and \ n2 != 1 and n3 != 1: break (e1, e2, e3, e4) = (valeur_alea(-10, 10), valeur_alea(-10, 10), @@ -114,7 +119,7 @@ def valeurs_puissances(): # renvoie un tuple contenant les valeurs pour les deu a = verifie_type((n1, n2, n3, e1, e2, e3, e4)) while True: (b1, b2) = (valeur_alea(2, maxi), valeur_alea(2, maxi)) - (b1, b2) = (b1 / pgcd(b1, b2), b2 / pgcd(b1, b2)) + (b1, b2) = (old_div(b1, pgcd(b1, b2)), old_div(b2, pgcd(b1, b2))) if b1 != 1 and b2 != 1: break (n1, n2) = ((b1 * valeur_alea(2, maxi)) * 10 ** randrange(-emax, emax + @@ -128,7 +133,7 @@ def valeurs_puissances(): # renvoie un tuple contenant les valeurs pour les deu return (a, b) def tex_puissances(): - sd = string.maketrans('.', ',') # convertit les . en , (separateur decimal) + sd = str.maketrans('.', ',') # convertit les . en , (separateur decimal) valeurs = valeurs_puissances() i = randrange(2) exo = ['\\exercice''', u"Calculer les expressions suivantes et donner l'écriture scientifique du résultat."] @@ -139,7 +144,7 @@ def tex_puissances(): cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_0(valeurs[i]).translate(sd) + '\\] ') cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_1(valeurs[i]).translate(sd) + '\\] ') cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_2(valeurs[i]).translate(sd) + '\\] ') - if int(math.floor(math.log10(((valeurs[i][0] * valeurs[i][1]) * 1.) / valeurs[i][2]))) != \ + if int(math.floor(math.log10(old_div(((valeurs[i][0] * valeurs[i][1]) * 1.), valeurs[i][2])))) != \ 0: cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_3(valeurs[i]).translate(sd) + '\\] ') cor.append(u'\\[ \\boxed{\\thenocalcul = ' + tex_puissances_4(valeurs[i]).translate(sd) + '} \\] ') @@ -149,8 +154,8 @@ def tex_puissances(): cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_0(valeurs[1 - i]).translate(sd) + '\\] ') cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_1(valeurs[1 - i]).translate(sd) + '\\] ') cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_2(valeurs[1 - i]).translate(sd) + '\\] ') - if int(math.floor(math.log10(((valeurs[1 - i][0] * valeurs[1 - i][1]) * 1.) / - valeurs[1 - i][2]))) != 0: + if int(math.floor(math.log10(old_div(((valeurs[1 - i][0] * valeurs[1 - i][1]) * 1.), + valeurs[1 - i][2])))) != 0: cor.append(u'\\[ \\thenocalcul = ' + tex_puissances_3(valeurs[1 - i]).translate(sd) + '\\] ') cor.append(u'\\[ \\boxed{\\thenocalcul = ' + tex_puissances_4(valeurs[1 - i]).translate(sd) + '} \\] ') exo.append('\\end{multicols}') diff --git a/src/pyromaths/ex/troisiemes/racines.py b/src/pyromaths/ex/troisiemes/racines.py index 719648db..c3a5cd51 100644 --- a/src/pyromaths/ex/troisiemes/racines.py +++ b/src/pyromaths/ex/troisiemes/racines.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import range from pyromaths.outils import Arithmetique import random from pyromaths.outils.Affichage import tex_coef diff --git a/src/pyromaths/ex/troisiemes/systemes.py b/src/pyromaths/ex/troisiemes/systemes.py index c88e4671..c843526e 100644 --- a/src/pyromaths/ex/troisiemes/systemes.py +++ b/src/pyromaths/ex/troisiemes/systemes.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import range from pyromaths.outils import Arithmetique from pyromaths.outils.Affichage import TeX, tex_coef diff --git a/src/pyromaths/interface.py b/src/pyromaths/interface.py index fa2fba20..8a64b446 100644 --- a/src/pyromaths/interface.py +++ b/src/pyromaths/interface.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,13 +20,28 @@ # along with this program; if notPopen, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from PyQt4 import QtGui, QtCore +from __future__ import absolute_import +from __future__ import division +from __future__ import unicode_literals +from __future__ import print_function +from builtins import str +from builtins import range +from past.utils import old_div +from builtins import object +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QFileDialog, QMessageBox import os, lxml, codecs, sys -from outils import System -from Values import CONFIGDIR, DATADIR, COPYRIGHTS, VERSION, ICONDIR -from Values import lesfiches +from .outils import System +from .Values import CONFIGDIR, DATADIR, COPYRIGHTS, VERSION, ICONDIR +from .Values import lesfiches from operator import itemgetter +try: + QString = str +except NameError: + # Python 3 + QString = str + class Ui_MainWindow(object): def __init__(self, *args, **kwargs): super(Ui_MainWindow, self).__init__(*args, **kwargs) @@ -50,48 +65,48 @@ def setupUi(self, MainWindow): MainWindow.setFont(font) # sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) ## Widget principal - self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget = QtWidgets.QWidget(MainWindow) MainWindow.setCentralWidget(self.centralwidget) ## Grille principale - self.gridLayout = QtGui.QGridLayout(self.centralwidget) + self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) #============================================================ # Boutons créer, quitter et annuler #============================================================ ## Conteneur vertical - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setMargin(9) + self.verticalLayout = QtWidgets.QVBoxLayout() + self.verticalLayout.setContentsMargins(9, 9, 9, 9) self.gridLayout.addLayout(self.verticalLayout, 0, 1, 1, 1) ## Bouton Créer - self.pushButton_ok = QtGui.QPushButton(self.centralwidget) + self.pushButton_ok = QtWidgets.QPushButton(self.centralwidget) self.verticalLayout.addWidget(self.pushButton_ok) self.pushButton_ok.setText(_(u"Créer")) if sys.platform != "darwin": # Cas de Mac OS X. self.pushButton_ok.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(243, 165, 30, 255), stop:1 rgba(255, 247, 177, 255));") - QtCore.QObject.connect(self.pushButton_ok, QtCore.SIGNAL("clicked()"), self.creer_les_exercices) + self.pushButton_ok.clicked.connect(self.creer_les_exercices) ## Bouton Quitter - self.pushButton_quit = QtGui.QPushButton(self.centralwidget) + self.pushButton_quit = QtWidgets.QPushButton(self.centralwidget) self.verticalLayout.addWidget(self.pushButton_quit) self.pushButton_quit.setText(_("Quitter")) if sys.platform != "darwin": # Cas de Mac OS X. self.pushButton_quit.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(243, 165, 30, 255), stop:1 rgba(255, 247, 177, 255));") - QtCore.QObject.connect(self.pushButton_quit, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()")) + self.pushButton_quit.clicked.connect(QtWidgets.QApplication.quit) ## Bouton Réinitialiser - self.pushButton_erase = QtGui.QPushButton(self.centralwidget) + self.pushButton_erase = QtWidgets.QPushButton(self.centralwidget) self.verticalLayout.addWidget(self.pushButton_erase) self.pushButton_erase.setText(_(u"Réinitialiser")) if sys.platform != "darwin": # Cas de Mac OS X. self.pushButton_erase.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(243, 165, 30, 255), stop:1 rgba(255, 247, 177, 255));") - QtCore.QObject.connect(self.pushButton_erase, QtCore.SIGNAL("clicked()"), self.effacer_choix_exercices) + self.pushButton_erase.clicked.connect(self.effacer_choix_exercices) ## Espace Vertical - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) #============================================================ # Onglets de la zone centrale #============================================================ ## Construction d'une zone d'onglet - self.tabWidget = QtGui.QTabWidget(self.centralwidget) + self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) self.tabWidget.setAutoFillBackground(True) self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) @@ -109,13 +124,13 @@ def setupUi(self, MainWindow): # Onglet options #============================================================ ## Creation d'une zone de scroll - self.tab_option_scroll = QtGui.QScrollArea(self.tabWidget) - self.tab_option_scroll.setFrameStyle(QtGui.QFrame.StyledPanel) + self.tab_option_scroll = QtWidgets.QScrollArea(self.tabWidget) + self.tab_option_scroll.setFrameStyle(QtWidgets.QFrame.StyledPanel) self.tab_option_scroll.setWidgetResizable(True) self.tabWidget.addTab(self.tab_option_scroll, _("Options")) ############## Onglet options - self.tab_options = QtGui.QWidget(self.tab_option_scroll) + self.tab_options = QtWidgets.QWidget(self.tab_option_scroll) if sys.platform != "darwin": # Cas de Mac OS X. self.tab_options.setStyleSheet("background-color: rgb(251, 245, 225);") self.tab_option_scroll.setWidget(self.tab_options) @@ -123,64 +138,64 @@ def setupUi(self, MainWindow): - self.gridLayout_2 = QtGui.QGridLayout(self.tab_options) - self.horizontalLayout_options1 = QtGui.QHBoxLayout() + self.gridLayout_2 = QtWidgets.QGridLayout(self.tab_options) + self.horizontalLayout_options1 = QtWidgets.QHBoxLayout() ############## Layout pour les noms d'options, en haut à gauche - self.verticalLayout_16 = QtGui.QVBoxLayout() + self.verticalLayout_16 = QtWidgets.QVBoxLayout() ############## Label nom du fichier - self.opt_nom_fichier = QtGui.QLabel(self.tab_options) + self.opt_nom_fichier = QtWidgets.QLabel(self.tab_options) self.opt_nom_fichier.setText(_(u"Nom par défaut du fichier : ")) self.verticalLayout_16.addWidget(self.opt_nom_fichier) ############## Label chemin par défaut pour l'enregistrement des fichiers - self.opt_chemin_fichier = QtGui.QLabel(self.tab_options) + self.opt_chemin_fichier = QtWidgets.QLabel(self.tab_options) self.opt_chemin_fichier.setText(_(u"Chemin par défaut pour enregistrer les fichiers : ")) self.verticalLayout_16.addWidget(self.opt_chemin_fichier) ############## Label titre des fiches - self.opt_titre_fiche = QtGui.QLabel(self.tab_options) + self.opt_titre_fiche = QtWidgets.QLabel(self.tab_options) self.opt_titre_fiche.setText(_("Titre de la fiche d'exercices : ")) self.verticalLayout_16.addWidget(self.opt_titre_fiche) self.horizontalLayout_options1.addLayout(self.verticalLayout_16) ############## Layout pour les noms d'options, en haut à droite - self.verticalLayout_17 = QtGui.QVBoxLayout() + self.verticalLayout_17 = QtWidgets.QVBoxLayout() ############## LineEdit nom du fichier - self.nom_fichier = QtGui.QLineEdit(self.tab_options) + self.nom_fichier = QtWidgets.QLineEdit(self.tab_options) self.nom_fichier.setText(self.config['nom_fichier']) self.nom_fichier.setStyleSheet("background-color: rgb(255, 255, 255);") self.verticalLayout_17.addWidget(self.nom_fichier) ############## LineEdit chemin par défaut pour l'enregistrement des fichiers - self.horizontalLayout_chemin_fichier = QtGui.QHBoxLayout() - self.chemin_fichier = QtGui.QLineEdit(self.tab_options) + self.horizontalLayout_chemin_fichier = QtWidgets.QHBoxLayout() + self.chemin_fichier = QtWidgets.QLineEdit(self.tab_options) self.chemin_fichier.setText(self.config['chemin_fichier']) self.chemin_fichier.setStyleSheet("background-color: rgb(255, 255, 255);") self.horizontalLayout_chemin_fichier.addWidget(self.chemin_fichier) ############## Bouton parcourir - self.pushButton_parcourir = QtGui.QPushButton(self.tab_options) + self.pushButton_parcourir = QtWidgets.QPushButton(self.tab_options) self.pushButton_parcourir.setText(_("Parcourir")) if sys.platform != "darwin": # Cas de Mac OS X. self.pushButton_parcourir.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(243, 165, 30, 255), stop:1 rgba(255, 247, 177, 255));") self.horizontalLayout_chemin_fichier.addWidget(self.pushButton_parcourir) self.verticalLayout_17.addLayout(self.horizontalLayout_chemin_fichier) - QtCore.QObject.connect(self.pushButton_parcourir, QtCore.SIGNAL("clicked()"), self.option_parcourir) + self.pushButton_parcourir.clicked.connect(self.option_parcourir) ############## LineEdit titre des fiches - self.titre_fiche = QtGui.QLineEdit(self.tab_options) + self.titre_fiche = QtWidgets.QLineEdit(self.tab_options) self.titre_fiche.setText(self.config['titre_fiche']) self.titre_fiche.setStyleSheet("background-color: rgb(255, 255, 255);") self.verticalLayout_17.addWidget(self.titre_fiche) @@ -189,25 +204,25 @@ def setupUi(self, MainWindow): ############## Ligne de séparation - self.line = QtGui.QFrame(self.tab_options) - self.line.setFrameShape(QtGui.QFrame.HLine) - self.line.setFrameShadow(QtGui.QFrame.Sunken) + self.line = QtWidgets.QFrame(self.tab_options) + self.line.setFrameShape(QtWidgets.QFrame.HLine) + self.line.setFrameShadow(QtWidgets.QFrame.Sunken) self.gridLayout_2.addWidget(self.line, 1, 0, 1, 2) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.verticalLayout_21 = QtGui.QVBoxLayout() + self.horizontalLayout_3 = QtWidgets.QHBoxLayout() + self.verticalLayout_21 = QtWidgets.QVBoxLayout() ############## CheckBox "corrigés ou non" - self.checkBox_corrige = QtGui.QCheckBox(self.tab_options) + self.checkBox_corrige = QtWidgets.QCheckBox(self.tab_options) self.checkBox_corrige.setText(_(u"Créer le corrigé")) self.checkBox_corrige.setToolTip(_(u"Pyromaths doit-il créer la fiche de correction détaillée?")) self.checkBox_corrige.setChecked(int(self.config['corrige'])) self.verticalLayout_21.addWidget(self.checkBox_corrige) - QtCore.QObject.connect(self.checkBox_corrige, QtCore.SIGNAL("stateChanged(int)"), self.option_corrige) + self.checkBox_corrige.stateChanged[int].connect(self.option_corrige) ############## CheckBox "pdf ou non" - self.checkBox_pdf = QtGui.QCheckBox(self.tab_options) + self.checkBox_pdf = QtWidgets.QCheckBox(self.tab_options) self.checkBox_pdf.setText(_(u"Créer le pdf")) self.checkBox_pdf.setToolTip(_(u"Pyromaths doit-il créer les fiches au format pdf ?")) self.checkBox_pdf.setChecked(int(self.config['pdf'])) @@ -215,7 +230,7 @@ def setupUi(self, MainWindow): ############## CheckBox "pdf ou non" - self.checkBox_unpdf = QtGui.QCheckBox(self.tab_options) + self.checkBox_unpdf = QtWidgets.QCheckBox(self.tab_options) self.checkBox_unpdf.setText(_(u"Créer un seul pdf")) self.checkBox_unpdf.setToolTip(_(u"Le corrigé et les exercices doivent-ils être dans le même document ?")) self.checkBox_unpdf.setChecked(int(self.config['unpdf'])) @@ -224,21 +239,21 @@ def setupUi(self, MainWindow): ############## Espace self.horizontalLayout_3.addLayout(self.verticalLayout_21) - spacerItem13 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacerItem13 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem13) - self.verticalLayout_20 = QtGui.QVBoxLayout() - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.verticalLayout_18 = QtGui.QVBoxLayout() + self.verticalLayout_20 = QtWidgets.QVBoxLayout() + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.verticalLayout_18 = QtWidgets.QVBoxLayout() ############## Label niveau - self.opt_niveau = QtGui.QLabel(self.tab_options) + self.opt_niveau = QtWidgets.QLabel(self.tab_options) self.opt_niveau.setText(_("Niveau :")) self.verticalLayout_18.addWidget(self.opt_niveau) ############## Label Modèle - self.label_modele = QtGui.QLabel(self.tab_options) + self.label_modele = QtWidgets.QLabel(self.tab_options) self.label_modele.setText(_(u"Modèle de mise en page :")) # self.label_modele.setEnabled(False) self.verticalLayout_18.addWidget(self.label_modele) @@ -246,11 +261,11 @@ def setupUi(self, MainWindow): ############## Layout pour les noms d'options, en bas à droite - self.verticalLayout_19 = QtGui.QVBoxLayout() + self.verticalLayout_19 = QtWidgets.QVBoxLayout() ############## ComboBox niveau - self.comboBox_niveau = QtGui.QComboBox(self.tab_options) + self.comboBox_niveau = QtWidgets.QComboBox(self.tab_options) self.comboBox_niveau.setStyleSheet("background-color: rgb(255, 255, 255);") self.comboBox_niveau.setEditable(True) # l’utilisateur peut entrer son propre texte self.comboBox_niveau.addItem(_("Classe de 6\\ieme")) @@ -262,7 +277,7 @@ def setupUi(self, MainWindow): ############## ComboBox modèles - self.comboBox_modele = QtGui.QComboBox(self.tab_options) + self.comboBox_modele = QtWidgets.QComboBox(self.tab_options) self.comboBox_modele.setStyleSheet("background-color: rgb(255, 255, 255);") modeles = os.listdir(os.path.join(DATADIR, 'templates')) modeles_home = os.listdir(os.path.join(CONFIGDIR, 'templates')) @@ -276,7 +291,7 @@ def setupUi(self, MainWindow): count += 1 for element in modeles_home: if os.path.splitext(element)[1] == ".tex": - self.comboBox_modele.addItem(QtCore.QString()) + self.comboBox_modele.addItem(QString()) self.comboBox_modele.setItemText(count, str(element[:len(element) - 4])) if element == self.config['modele']: self.comboBox_modele.setCurrentIndex(count) @@ -290,46 +305,46 @@ def setupUi(self, MainWindow): ############## Bouton enregistrer - self.pushButton_enr_opt = QtGui.QPushButton(self.tab_options) + self.pushButton_enr_opt = QtWidgets.QPushButton(self.tab_options) self.pushButton_enr_opt.setText(_(u"Enregistrer dans les préférences")) if sys.platform != "darwin": # Cas de Mac OS X. self.pushButton_enr_opt.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(243, 165, 30, 255), stop:1 rgba(255, 247, 177, 255));") - QtCore.QObject.connect(self.pushButton_enr_opt, QtCore.SIGNAL("clicked()"), self.enregistrer_config) + self.pushButton_enr_opt.clicked.connect(self.enregistrer_config) self.gridLayout_2.addWidget(self.pushButton_enr_opt, 4, 1, 1, 1) - spacerItem14 = QtGui.QSpacerItem(20, 177, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + spacerItem14 = QtWidgets.QSpacerItem(20, 177, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout_2.addItem(spacerItem14, 3, 1, 1, 1) - spacerItem15 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacerItem15 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.gridLayout_2.addItem(spacerItem15, 4, 0, 1, 1) #============================================================ # Barre de menus et de status #============================================================ ## Construction de la barre - self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 700, 22)) MainWindow.setMenuBar(self.menubar) ## Menu Fichier if sys.platform != "darwin": # Cas de Mac OS X. - self.menuFichier = QtGui.QMenu(self.menubar) + self.menuFichier = QtWidgets.QMenu(self.menubar) self.menuFichier.setTitle(_("Fichier")) ## Action Quitter - self.actionQuitter = QtGui.QAction(MainWindow) + self.actionQuitter = QtWidgets.QAction(MainWindow) self.actionQuitter.setText(_("Quitter")) self.actionQuitter.setShortcut('Ctrl+Q') - QtCore.QObject.connect(self.actionQuitter, QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) + self.actionQuitter.triggered.connect(QtWidgets.QApplication.quit) ## Menu Aide - self.menu_propos = QtGui.QMenu(self.menubar) + self.menu_propos = QtWidgets.QMenu(self.menubar) self.menu_propos.setTitle(_("Aide")) ## Action Accéder au site - self.actionAcceder_au_site = QtGui.QAction(MainWindow) + self.actionAcceder_au_site = QtWidgets.QAction(MainWindow) self.actionAcceder_au_site.setText(_(u"Accéder au site")) - QtCore.QObject.connect(self.actionAcceder_au_site, QtCore.SIGNAL("triggered()"), self.site) + self.actionAcceder_au_site.triggered.connect(self.site) ## Action À propos - self.action_a_propos = QtGui.QAction(MainWindow) + self.action_a_propos = QtWidgets.QAction(MainWindow) self.action_a_propos.setText(_(u"À propos")) - self.action_a_propos.setMenuRole(QtGui.QAction.AboutRole) - QtCore.QObject.connect(self.action_a_propos, QtCore.SIGNAL("triggered()"), self.about) + self.action_a_propos.setMenuRole(QtWidgets.QAction.AboutRole) + self.action_a_propos.triggered.connect(self.about) ## Construction du menu if sys.platform != "darwin": self.menuFichier.addSeparator() @@ -345,10 +360,10 @@ def setupUi(self, MainWindow): # Barre d'état #============================================================ ## Construction de la barre d'état - self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar = QtWidgets.QStatusBar(MainWindow) MainWindow.setStatusBar(self.statusbar) ## Message d'aide - self.statusbar_label= QtGui.QLabel(self.statusbar) + self.statusbar_label= QtWidgets.QLabel(self.statusbar) self.statusbar_label.setText(_(u"Pour avoir un aperçu d'un exercice, positionner le curseur de la souris sur le point d'interrogation.")) self.statusbar.addWidget(self.statusbar_label,1) @@ -361,7 +376,7 @@ def setupUi(self, MainWindow): # ## Gestion des erreurs def erreur_critique(self, message): """Dialogue si pyromaths.xml est défectueux.""" - reply = QtGui.QMessageBox.critical(self, "Erreur critique", message) + reply = QtWidgets.QMessageBox.critical(self, "Erreur critique", message) if reply: sys.exit(1) @@ -406,15 +421,15 @@ def about(self): Guillaume Barthélémy pour ses exercices ;
  • - Nicolas Bissonnier pour son arrivée dans l'équipe de développement ; -
  • -
  • Didier Roche pour l'intégration de Pyromaths dans les dépôts Ubuntu ;
  • Olivier Cornu pour son travail sur l'API exercice et sur la diffusion de Pyromaths via Makefile et Setup.py ;
  • + Louis Paternault pour son travail sur Pyromaths ; +
  • +
  • Jacqueline Gouguenheim-Desloy a porté Pyromaths sur Mac OS X à ses débuts. Son soutien et son amitié nous ont été précieux. Sa disparition est une perte douloureuse pour la communauté du logiciel libre.
  • @@ -428,26 +443,27 @@ def about(self): banniere = os.path.join(DATADIR, 'images', 'pyromaths.png') else: banniere = os.path.join(DATADIR, 'images', 'pyromaths-banniere.png') - QtGui.QMessageBox.about(self.centralwidget, _(u'À propos de Pyromaths'), text % (banniere, VERSION, COPYRIGHTS)) + # self.setGeometry(10,10,620,200) + QtWidgets.QMessageBox.about(None, _(u'À propos de Pyromaths'), text % (banniere, VERSION, COPYRIGHTS)) def creer_les_exercices(self): """Vérifie si la liste d'exercices n'est pas vide puis sélectionne les noms des fichiers exercices et corrigés""" self.valide_options() if self.liste_creation == [] : - QtGui.QMessageBox.warning(None, _('Attention !'), + QtWidgets.QMessageBox.warning(None, _('Attention !'), _(u"Veuillez sélectionner des exercices..."), - QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.Ok) else: parametres = { 'creer_pdf': self.checkBox_pdf.isChecked(), 'creer_unpdf': self.checkBox_unpdf.isChecked() and self.checkBox_unpdf.isEnabled(), - 'titre': unicode(self.titre_fiche.text()), + 'titre': str(self.titre_fiche.text()), 'corrige': self.checkBox_corrige.isChecked(), - 'niveau': unicode(self.comboBox_niveau.currentText()), - 'nom_fichier': unicode(self.nom_fichier.text()), - 'chemin_fichier': unicode(self.chemin_fichier.text()), - 'modele': unicode(self.comboBox_modele.currentText() + '.tex'), + 'niveau': str(self.comboBox_niveau.currentText()), + 'nom_fichier': str(self.nom_fichier.text()), + 'chemin_fichier': str(self.chemin_fichier.text()), + 'modele': str(self.comboBox_modele.currentText() + '.tex'), 'datadir': DATADIR, 'configdir': CONFIGDIR } @@ -459,9 +475,9 @@ def creer_les_exercices(self): niveau = self.liste_creation[i][0] exo = self.liste_creation[i][1] liste.append(self.lesfiches[niveau][2][exo]) - self.List = QtGui.QListWidget() + self.List = QtWidgets.QListWidget() for i in range(len(liste)): - item = QtGui.QListWidgetItem(liste[i].description) + item = QtWidgets.QListWidgetItem(liste[i].description) item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsDragEnabled) @@ -490,13 +506,13 @@ def enregistrer_config(self): tree = lxml.etree.parse(self.configfile) root = tree.getroot() options = root.find('options') - options .find('nom_fichier').text = unicode(self.nom_fichier.text()) - options .find('chemin_fichier').text = unicode(self.chemin_fichier.text()) - options .find('titre_fiche').text = unicode(self.titre_fiche.text()) + options .find('nom_fichier').text = str(self.nom_fichier.text()) + options .find('chemin_fichier').text = str(self.chemin_fichier.text()) + options .find('titre_fiche').text = str(self.titre_fiche.text()) options .find('corrige').text = str(self.checkBox_corrige.isChecked()) options .find('pdf').text = str(self.checkBox_pdf.isChecked()) options .find('unpdf').text = str(self.checkBox_unpdf.isChecked()) - options .find('modele').text = unicode(self.comboBox_modele.currentText() + '.tex') + options .find('modele').text = str(self.comboBox_modele.currentText() + '.tex') f = codecs.open(self.configfile, encoding='utf-8', mode='w') f.write(lxml.etree.tostring(root, pretty_print=True, encoding="UTF-8", @@ -517,8 +533,8 @@ def lire_config(self, section): return config def option_parcourir(self): - d0 = QtGui.QFileDialog().getExistingDirectory (None, _(u"Dossier où créer les fiches"), - self.config['chemin_fichier'], QtGui.QFileDialog.ShowDirsOnly) + d0 = QtWidgets.QFileDialog().getExistingDirectory (None, _(u"Dossier où créer les fiches"), + self.config['chemin_fichier'], QtWidgets.QFileDialog.ShowDirsOnly) if d0: self.chemin_fichier.setText(d0) @@ -563,7 +579,7 @@ def valide_options(self): # Classe ChoixOrdreExos #================================================================ -class ChoixOrdreExos(QtGui.QDialog): +class ChoixOrdreExos(QtWidgets.QDialog): """À appeler de la façon suivante : form = ChoixOrdreExos(liste, LesFiches, parametres) Permet de choisir l'ordre dans lequel les exercices vont apparaître @@ -582,26 +598,26 @@ def __init__(self, liste, LesFiches, parametres, parent=None): self.lesfiches = LesFiches self.parametres = parametres self.List = liste - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle(_("Choisissez l'ordre des exercices")) - layout = QtGui.QHBoxLayout() + layout = QtWidgets.QHBoxLayout() - buttonBox = QtGui.QDialogButtonBox() + buttonBox = QtWidgets.QDialogButtonBox() buttonBox.setOrientation(QtCore.Qt.Vertical) - buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) + buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) self.List.setAlternatingRowColors(True) self.List.setDragEnabled(True) self.List.setAcceptDrops(True) - self.List.setDragDropMode(QtGui.QAbstractItemView.InternalMove) + self.List.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) self.List.setDropIndicatorShown(True) layout.addWidget(self.List) layout.addWidget(buttonBox) self.setLayout(layout) - QtCore.QObject.connect(buttonBox, QtCore.SIGNAL("accepted()"), self.accept) - QtCore.QObject.connect(buttonBox, QtCore.SIGNAL("rejected()"), self.close) + buttonBox.accepted.connect(self.accept) + buttonBox.rejected.connect(self.close) def accept(self): """Écrit une liste contenant la liste des exercices dans l'ordre choisit par l'utilisateur et demande à @@ -620,22 +636,28 @@ def valide(liste, LesFiches, parametres): #============================================================ # Choix des noms des fichiers exercices et corrigés #============================================================ - saveas = QtGui.QFileDialog() - filename = System.supprime_extension(parametres['nom_fichier'], - '.tex') - f0 = unicode(saveas.getSaveFileName(None, "Enregistrer sous...", - os.path.join(parametres['chemin_fichier'], - u'%s.tex' % filename), "Documents Tex (*.tex)")) + filename = System.supprime_extension(parametres['nom_fichier'], '.tex') + options = QFileDialog.Options() + options |= QFileDialog.DontUseNativeDialog + f0, _ = QFileDialog.getSaveFileName(None,"Enregistrer sous...", + os.path.join(parametres['chemin_fichier'], u'%s.tex' % filename), + "Documents Tex (*.tex);;All Files(*)", + options=options) + # f0 = unicode(saveas.getSaveFileName(None, "Enregistrer sous...", + # os.path.join(parametres['chemin_fichier'], + # u'%s.tex' % filename), "Documents Tex (*.tex)"))[0] + print(f0) + print(os.path.splitext(os.path.basename(f0))[0]) if f0: System.ajoute_extension(f0, '.tex') if corrige and not parametres['creer_unpdf']: - f1 = unicode(saveas.getSaveFileName(None, "Enregistrer sous...", + f1 = str(saveas.getSaveFileName(None, "Enregistrer sous...", os.path.join(os.path.dirname(f0), _(u"%s-corrige.tex") % os.path.splitext(os.path.basename(f0))[0]), - _("Documents Tex (*.tex)"))) + _("Documents Tex (*.tex)")))[0] else: - f1 = os.path.join(os.path.dirname(f0), _(u"%s-corrige.tex") % - os.path.splitext(os.path.basename(f0))[0]) + f1 = os.path.join(os.path.dirname(f0), + os.path.splitext(os.path.basename(f0))[0] + "-corrige.tex") if f1: if corrige: System.ajoute_extension(f1, '.tex') @@ -649,29 +671,29 @@ def valide(liste, LesFiches, parametres): # Classe Tab #================================================================ -class Tab(QtGui.QWidget): +class Tab(QtWidgets.QWidget): """Gère les onglets permettant de sélectionner des exercices""" def __init__(self, parent, level, onchange): - QtGui.QWidget.__init__(self) # Initialise la super-classe + QtWidgets.QWidget.__init__(self) # Initialise la super-classe self.titre = level[0] self.exos = level[2] - self.scroll = QtGui.QScrollArea(self) - self.scroll.setFrameStyle(QtGui.QFrame.StyledPanel) + self.scroll = QtWidgets.QScrollArea(self) + self.scroll.setFrameStyle(QtWidgets.QFrame.StyledPanel) self.scroll.setWidgetResizable(True) - self.widget = QtGui.QWidget(self.scroll) + self.widget = QtWidgets.QWidget(self.scroll) self.scroll.setWidget(self.widget) if sys.platform != "darwin": # Cas de Mac OS X. self.widget.setStyleSheet("background-color: rgb(251, 245, 225);") - self.layout = QtGui.QGridLayout(self.widget) + self.layout = QtWidgets.QGridLayout(self.widget) self.spinBox = [] # Crée les widgets des exercices nb_exos = len(self.exos) - spacer = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + spacer = QtWidgets.QSpacerItem(20, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) for i in range(nb_exos): self.add_exercise(i, onchange) - self.layout.addItem(spacer, (nb_exos + 1) / 2, 0, 1, 1) - self.layout.addItem(spacer, (nb_exos + 1) / 2, 1, 1, 1) + self.layout.addItem(spacer, old_div((nb_exos + 1), 2), 0, 1, 1) + self.layout.addItem(spacer, old_div((nb_exos + 1), 2), 1, 1, 1) # Ajoute ce tab au widget parent parent.addTab(self.scroll, self.titre) @@ -679,34 +701,34 @@ def __init__(self, parent, level, onchange): def add_exercise(self, i, onchange): """Ajoute l'exercice n°i à cet onglet""" - layout = QtGui.QHBoxLayout() + layout = QtWidgets.QHBoxLayout() # SpinBox - spinBox = QtGui.QSpinBox(self.widget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + spinBox = QtWidgets.QSpinBox(self.widget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(40) sizePolicy.setVerticalStretch(30) sizePolicy.setHeightForWidth(spinBox.sizePolicy().hasHeightForWidth()) spinBox.setSizePolicy(sizePolicy) spinBox.setToolTip(_(u"Choisissez le nombre d\'exercices de ce type à créer.")) spinBox.setStyleSheet("background-color: rgb(255, 255, 255);") - QtCore.QObject.connect(spinBox, QtCore.SIGNAL("valueChanged(int)"), onchange) + spinBox.valueChanged[int].connect(onchange) self.spinBox.append(spinBox) layout.addWidget(spinBox) # Image - img = QtGui.QLabel(self.widget) + img = QtWidgets.QLabel(self.widget) img.setText(r'' % os.path.join(DATADIR, 'images', 'whatsthis.png')) img.setToolTip(r'' % self.exos[i].thumb()) layout.addWidget(img) # Label - label = QtGui.QLabel(self.widget) + label = QtWidgets.QLabel(self.widget) label.setText(self.exos[i].description) layout.addWidget(label) # Espacements - spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) layout.addItem(spacer) layout.addItem(spacer) # Ajoute cet exercice à l'onglet - self.layout.addLayout(layout, i / 2, i % 2, 1, 1) + self.layout.addLayout(layout, old_div(i, 2), i % 2, 1, 1) def reset(self): """Remet les compteurs à zéro""" diff --git a/src/pyromaths/outils/Affichage.py b/src/pyromaths/outils/Affichage.py index 6d181552..88995e59 100644 --- a/src/pyromaths/outils/Affichage.py +++ b/src/pyromaths/outils/Affichage.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -22,6 +22,8 @@ # # import re +from __future__ import unicode_literals +from builtins import str from pyromaths.classes import Racine from pyromaths.classes.Fractions import Fraction diff --git a/src/pyromaths/outils/Arithmetique.py b/src/pyromaths/outils/Arithmetique.py index d4d08b04..452c2d2a 100644 --- a/src/pyromaths/outils/Arithmetique.py +++ b/src/pyromaths/outils/Arithmetique.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div import math, random def pgcd(*n): @@ -104,7 +109,7 @@ def premier(n): :rtype: boolean """ - return not [x for x in xrange(2, int(math.sqrt(n)) + 1) + return not [x for x in range(2, int(math.sqrt(n)) + 1) if n % x == 0] def eratosthene(n): @@ -121,7 +126,7 @@ def eratosthene(n): :rtype: list """ - return [x for x in xrange(2, n) if premier(x)] + return [x for x in range(2, n) if premier(x)] def factor(n): @@ -141,12 +146,12 @@ def factor(n): :rtype: list """ premiers = [] - candidats = xrange(2, n + 1) + candidats = list(range(2, n + 1)) candidat = 2 while not premiers and candidat in candidats: if n % candidat == 0 and premier(candidat): premiers.append(candidat) - premiers = premiers + factor(n / candidat) + premiers = premiers + factor(old_div(n, candidat)) candidat += 1 return premiers @@ -175,7 +180,7 @@ def factorise(n): if n % candidate == 0: primes.append(candidate) primes_etapes.append(str(candidate)) - n = n / candidate + n = old_div(n, candidate) if n == 1: break primes_etapes.append(str(n)) @@ -250,7 +255,7 @@ def carrerise(n): if (primes.count(element) % 2 == 1): q[element] = 1 ncar = 1 - for element in q.iterkeys(): + for element in list(q.keys()): ncar *= element return ncar diff --git a/src/pyromaths/outils/Conversions.py b/src/pyromaths/outils/Conversions.py index 46df0d7b..203e6931 100644 --- a/src/pyromaths/outils/Conversions.py +++ b/src/pyromaths/outils/Conversions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +from __future__ import unicode_literals import math def radians(alpha): diff --git a/src/pyromaths/outils/Geometrie.py b/src/pyromaths/outils/Geometrie.py index ee8e4f18..3d1ba3b7 100644 --- a/src/pyromaths/outils/Geometrie.py +++ b/src/pyromaths/outils/Geometrie.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,9 +21,16 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import absolute_import +from __future__ import division +from __future__ import unicode_literals +from builtins import chr +from builtins import range +from builtins import object +from past.utils import old_div import math from random import randrange -from Conversions import degres, radians +from .Conversions import degres, radians def choix_points(n): """ choisit n points parmi A, B, C, ..., Z @@ -161,11 +168,11 @@ def choix_points(n): def trouve_couples_pythagore(max): ls = [] - for i in xrange(26): - for j in xrange(i - 1): + for i in range(26): + for j in range(i - 1): a = i b = j + 1 - for k in xrange(140): + for k in range(140): x = (2 * k + 1) * (a ** 2 - b ** 2) y = (2 * k + 1) * (2 * a * b) z = (2 * k + 1) * (a ** 2 + b ** 2) @@ -227,7 +234,7 @@ def cotation_h(A, B, longueur, couleur="", unite="cm"): # listecouples.append(tuple(listeinter)) # # return tuple(listecouples) -class Metapost: +class Metapost(object): def __init__(self): self.text = [] @@ -276,10 +283,10 @@ def triangle( # on donne les trois longueurs des 3 côtés if a and b and c: - alpha = degres(math.acos(((b ** 2 + c ** 2) - a ** 2 * 1.) / ((2 * - b) * c))) - beta = degres(math.acos(((c ** 2 + a ** 2) - b ** 2 * 1.) / ((2 * - c) * a))) + alpha = degres(math.acos(old_div(((b ** 2 + c ** 2) - a ** 2 * 1.), ((2 * + b) * c)))) + beta = degres(math.acos(old_div(((c ** 2 + a ** 2) - b ** 2 * 1.), ((2 * + c) * a)))) elif a and b and gamma: # Un angle et les deux côtés adjacents @@ -319,29 +326,29 @@ def triangle( pass # on sait faire elif beta and gamma and a: - c = (a * math.sin((gamma * math.pi) / 180)) / math.sin(((beta + - gamma) * math.pi) / 180) + c = old_div((a * math.sin(old_div((gamma * math.pi), 180))), math.sin(old_div(((beta + + gamma) * math.pi), 180))) alpha = (180 - beta) - gamma elif alpha and gamma and b: - c = (b * math.sin((gamma * math.pi) / 180)) / math.sin(((alpha + - gamma) * math.pi) / 180) + c = old_div((b * math.sin(old_div((gamma * math.pi), 180))), math.sin(old_div(((alpha + + gamma) * math.pi), 180))) beta = (180 - alpha) - gamma elif a and alpha and beta: # Deux angles et un côté non commun - c = (a * math.sin(((alpha + beta) * math.pi) / 180)) / math.sin((alpha * - math.pi) / 180) + c = old_div((a * math.sin(old_div(((alpha + beta) * math.pi), 180))), math.sin(old_div((alpha * + math.pi), 180))) elif a and alpha and gamma: - c = (a * math.sin((gamma * math.pi) / 180)) / math.sin((alpha * - math.pi) / 180) + c = old_div((a * math.sin(old_div((gamma * math.pi), 180))), math.sin(old_div((alpha * + math.pi), 180))) beta = (180 - alpha) - gamma elif b and beta and alpha: - c = (b * math.sin(((alpha + beta) * math.pi) / 180)) / math.sin((beta * - math.pi) / 180) + c = old_div((b * math.sin(old_div(((alpha + beta) * math.pi), 180))), math.sin(old_div((beta * + math.pi), 180))) elif b and beta and gamma: - c = (b * math.sin((gamma * math.pi) / 180)) / math.sin((beta * - math.pi) / 180) + c = old_div((b * math.sin(old_div((gamma * math.pi), 180))), math.sin(old_div((beta * + math.pi), 180))) alpha = (180 - beta) - gamma elif c and alpha and gamma: beta = (180 - alpha) - gamma @@ -385,22 +392,22 @@ def triangle( def triangle_angle_cotes_adjacents(self, a, b, gamma): c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(radians(gamma))) - alpha = 90. - gamma / 2 + degres(math.atan((((a - b) * 1.) / (a + b)) / - math.tan(radians(gamma / 2)))) - beta = 90. - gamma / 2 - degres(math.atan((a - b) * 1. / (a + b) / - math.tan(radians(gamma / 2)))) + alpha = 90. - old_div(gamma, 2) + degres(math.atan(old_div((old_div(((a - b) * 1.), (a + b))), + math.tan(radians(old_div(gamma, 2)))))) + beta = 90. - old_div(gamma, 2) - degres(math.atan((a - b) * 1. / (a + b) / + math.tan(radians(old_div(gamma, 2))))) return (c, beta, alpha) def triangle_angle_cote_adjacent_cote_oppose(self, b, c, beta): - if b <= c * math.sin((beta * math.pi) / 180): + if b <= c * math.sin(old_div((beta * math.pi), 180)): alpha = gamma = a = 0 # Pas possible de résoudre else: - gamma = degres(math.asin(((c * math.sin((beta * math.pi) / 180)) / - b) * 1.)) + gamma = degres(math.asin((old_div((c * math.sin(old_div((beta * math.pi), 180))), + b)) * 1.)) alpha = (180 - beta) - gamma - a = math.sqrt(b ** 2 - c ** 2 * math.sin((beta * math.pi) / - 180) ** 2) + c * math.cos((beta * math.pi) / - 180) + a = math.sqrt(b ** 2 - c ** 2 * math.sin(old_div((beta * math.pi), + 180)) ** 2) + c * math.cos(old_div((beta * math.pi), + 180)) return (a, alpha, gamma) diff --git a/src/pyromaths/outils/Polynomes.py b/src/pyromaths/outils/Polynomes.py index 32c8a7e5..54182687 100644 --- a/src/pyromaths/outils/Polynomes.py +++ b/src/pyromaths/outils/Polynomes.py @@ -1,4 +1,9 @@ # -*- coding: utf-8 -*- +from __future__ import division +from __future__ import unicode_literals +from builtins import str +from builtins import range +from past.utils import old_div from pyromaths.classes.Polynome import Polynome from .Arithmetique import pgcd @@ -11,7 +16,7 @@ def TeX_division(dividende, diviseur): '''renvoie une chaine de caractere TeX pour afficher la division en détail''' # quotient = Polynome({0:0}) - texquotient, restera = dividende / diviseur + texquotient, restera = old_div(dividende, diviseur) reste = dividende diviseur_degre = diviseur.deg sauve = min(dividende.puiss + restera.puiss) @@ -28,7 +33,7 @@ def TeX_division(dividende, diviseur): for dummy in range(i): string += " &" ajout_quotient_deg = reste.deg - diviseur_degre - facteur = reste.dictio[max(0, reste.deg)] / diviseur.dictio[diviseur.deg] + facteur = old_div(reste.dictio[max(0, reste.deg)], diviseur.dictio[diviseur.deg]) ajout_quotient = Polynome({ajout_quotient_deg:facteur}, var=dividende.var) soustrait_reste = ajout_quotient * diviseur string += tab_print(soustrait_reste, diviseur_degre + 1 - sauve, parenthese=True) @@ -116,7 +121,7 @@ def poly_racines_fractionnaires(rac_min, rac_max, denom1, X): break pol2 = pol2.simplifie() simplifie = abs(pgcd(pgcd(int(pol2[0]), int(pol2[1])), int(pol2[2]))) - pol2 = pol2 / simplifie + pol2 = old_div(pol2, simplifie) return pol2.simplifie() def poly_racines_entieres(rac_min, rac_max, X, a1=1): diff --git a/src/pyromaths/outils/Priorites3.py b/src/pyromaths/outils/Priorites3.py index 7727b8d6..09ab9c52 100644 --- a/src/pyromaths/outils/Priorites3.py +++ b/src/pyromaths/outils/Priorites3.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -25,6 +25,10 @@ #---------------------------------------------------------------------- # from Affichage import decimaux +from __future__ import absolute_import +from __future__ import unicode_literals +from builtins import str +from builtins import range from pyromaths.outils import Arithmetique @@ -642,7 +646,7 @@ def effectue_calcul(calcul): sol = eval('(' + calc[0] + ')**' + calc[2]) else: sol = eval("".join(calc)) - if isinstance(sol, basestring): sol = splitting(sol) + if isinstance(sol, str): sol = splitting(sol) elif isinstance(sol, (int, float)): sol = [str(sol)] elif isinstance(sol, (Polynome, Fraction, SquareRoot)): sol = [repr(sol)] else : @@ -761,17 +765,17 @@ def texify(liste_calculs): from pyromaths.classes.PolynomesCollege import Polynome from pyromaths.classes.Fractions import Fraction from pyromaths.classes.SquareRoot import SquareRoot - from Affichage import decimaux + from .Affichage import decimaux ls = [] enluminures = {'indice': r'_{', 'cancel':r'\cancel{'} isEnlumine = {'indice': False, 'cancel':False} for calcul in liste_calculs: - if isinstance(calcul, basestring): calcul = splitting(calcul) + if isinstance(calcul, str): calcul = splitting(calcul) s = "" puiss = 0 for index in range(len(calcul)): el = calcul[index] - for cle in isEnlumine.keys(): + for cle in list(isEnlumine.keys()): if isEnlumine[cle] and (not isinstance(el, list) or el[1] != cle): s += '}' isEnlumine[cle] = False @@ -795,7 +799,7 @@ def texify(liste_calculs): p.monomes[0][0] < 0 or \ (p.monomes[0][0] != 1 and isinstance(p.monomes[0][0], Fraction) and p.monomes[0][0].d != 1)) and q and q == "**"): s += "(" + str(p) + ")" - elif s and s[-1] == "+" and p.monomes[0][0] < 0: + elif s and s[-1] == "+" and type(p.monomes[0][0]) == int and p.monomes[0][0] < 0: s = s[:-1] s += str(p) else: @@ -864,7 +868,7 @@ def texify(liste_calculs): if puiss == 1 and s[-1] != r"{": puiss = 0 s += "}" - for cle in isEnlumine.keys(): + for cle in list(isEnlumine.keys()): if isEnlumine[cle] and (not isinstance(el, list) or el[1] != cle): s += '}' s = s.replace("**{", "^{") @@ -898,9 +902,9 @@ def plotify(calcul): """ from pyromaths.classes.PolynomesCollege import Polynome from pyromaths.classes.Fractions import Fraction - from Affichage import decimaux + from .Affichage import decimaux - if isinstance(calcul, basestring): calcul = splitting(calcul) + if isinstance(calcul, str): calcul = splitting(calcul) s = "" puiss = 0 for i in range(len(calcul)): diff --git a/src/pyromaths/outils/System.py b/src/pyromaths/outils/System.py index a61fbbfc..f13d6d55 100644 --- a/src/pyromaths/outils/System.py +++ b/src/pyromaths/outils/System.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,10 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import print_function +from __future__ import unicode_literals +from builtins import str +from builtins import range import sys, os, codecs from lxml import etree from lxml import _elementpath as DONTUSE # Astuce pour inclure lxml dans Py2exe @@ -72,7 +76,7 @@ def create_config_file(): etree.SubElement(subchild, "email").text = u"jerome.ortais@pyromaths.org" etree.SubElement(subchild, "site").text = "http://www.pyromaths.org" - return etree.tostring(root, pretty_print=True, encoding=unicode) + return etree.tostring(root, pretty_print=True) def indent(elem, level=0): """Indente correctement les fichiers xml. @@ -127,7 +131,7 @@ def modify_config_file(fichier): oldtag.text = element.text if modifie: f = codecs.open(os.path.join(CONFIGDIR, "pyromaths.xml"), encoding='utf-8', mode='w') - f.write(etree.tostring(indent(oldroot), pretty_print=True, encoding=unicode)) + f.write(etree.tostring(indent(oldroot), pretty_print=True, encoding=str)) f.close() #============================================================== @@ -162,8 +166,8 @@ def creation(parametres): 'titre': unicode(self.lineEdit_titre.text()), 'niveau': unicode(self.comboBox_niveau.currentText()), }""" - exo = unicode(parametres['fiche_exo']) - cor = unicode(parametres['fiche_cor']) + exo = str(parametres['fiche_exo']) + cor = str(parametres['fiche_cor']) f0 = codecs.open(exo, encoding='utf-8', mode='w') f1 = codecs.open(cor, encoding='utf-8', mode='w') @@ -223,13 +227,14 @@ def creation(parametres): else: # Pas le chemin pour les autres, au cas où il y aurait un accent dans # le chemin (latex ne gère pas le 8 bits) - f0noext = os.path.splitext(os.path.basename(exo))[0].encode(sys.getfilesystemencoding()) - f1noext = os.path.splitext(os.path.basename(cor))[0].encode(sys.getfilesystemencoding()) + f0noext = os.path.splitext(os.path.basename(exo))[0] + f1noext = os.path.splitext(os.path.basename(cor))[0] if parametres['creer_pdf']: from subprocess import call _preprocess_pipe(os.path.join(dir0, '{}.tex'.format(f0noext)), parametres.get('pipe', None)) os.chdir(dir0) + print(dir0) latexmkrc(f0noext) log = open('%s-pyromaths.log' % f0noext, 'w') if socket.gethostname() == "sd-94439.pyromaths.org": @@ -237,11 +242,11 @@ def creation(parametres): call(["latexmk", "-shell-escape", "-silent", "-interaction=nonstopmode", "-output-directory=%s" % dir0, "-pdfps", "%s.tex" % f0noext], env=os.environ, stdout=log) call(["latexmk", "-c", "-silent", "-output-directory=%s" % dir0], env=os.environ, stdout=log) elif os.name == 'nt': - call(["latexmk", "-pdfps", "-shell-escape", "-silent", "-interaction=nonstopmode", "%s.tex" % f0noext], env={"PATH": os.environ['PATH'], "WINDIR": os.environ['WINDIR'], 'USERPROFILE': os.environ['USERPROFILE']}, stdout=log) + call(["latexmk", "%s.tex" % f0noext], env={"PATH": os.environ['PATH'], "WINDIR": os.environ['WINDIR'], 'USERPROFILE': os.environ['USERPROFILE']}, stdout=log) call(["latexmk", "-silent", "-c"], env={"PATH": os.environ['PATH'], "WINDIR": os.environ['WINDIR'], 'USERPROFILE': os.environ['USERPROFILE']}, stdout=log) else: - call(["latexmk", "-pdfps", "-shell-escape", "-silent", "-interaction=nonstopmode", "%s.tex" % f0noext], stdout=log) - call(["latexmk", "-silent", "-c", "-f"], stdout=log) + call(["latexmk", "-silent", "%s.tex" % f0noext], stdout=log) + call(["latexmk", "-silent", "-c"], stdout=log) log.close() nettoyage(f0noext) if not "openpdf" in parametres or parametres["openpdf"]: @@ -264,8 +269,8 @@ def creation(parametres): call(["latexmk", "%s.tex" % f1noext], env={"PATH": os.environ['PATH'], "WINDIR": os.environ['WINDIR'], 'USERPROFILE': os.environ['USERPROFILE']}, stdout=log) call(["latexmk", "-c"], env={"PATH": os.environ['PATH'], "WINDIR": os.environ['WINDIR'], 'USERPROFILE': os.environ['USERPROFILE']}, stdout=log) else: - call(["latexmk", "%s.tex" % f1noext], stdout=log) - call(["latexmk", "-c"], stdout=log) + call(["latexmk", "-silent", "%s.tex" % f1noext], stdout=log) + call(["latexmk", "-silent", "-c"], stdout=log) log.close() nettoyage(f1noext) if not "openpdf" in parametres or parametres["openpdf"]: @@ -287,7 +292,9 @@ def latexmkrc(basefilename): latexmkrc.write('add_cus_dep("asy","eps",0,"asy");\n') latexmkrc.write('add_cus_dep("asy","pdf",0,"asy");\n') latexmkrc.write('add_cus_dep("asy","tex",0,"asy");\n') - latexmkrc.write('push @generated_exts, \'pre\', \'dvi\', \'ps\', \'auxlock\', \'fdb_latexmk\', \'fls\', \'out\', \'aux\';\n') + #latexmkrc.write('push @generated_exts, \'pre\', \'dvi\', \'ps\', \'auxlock\', \'fdb_latexmk\', \'fls\', \'out\', \'aux\';\n') + latexmkrc.write('$cleanup_mode = 2;\n') + #latexmkrc.write('@generated_exts = qw(4ct 4tc acn acr alg aux auxlock bbl dvi eps fls glg glo gls idv idx ind ist lg lof lot nav net out pre ps ptc run.xml snm thm tmp toc vrb xdv xref);') latexmkrc.write('$clean_ext .= " %R-?.tex %R-??.tex %R-figure*.dpth %R-figure*.dvi %R-figure*.eps %R-figure*.log %R-figure*.md5 %R-figure*.pre %R-figure*.ps %R-figure*.asy %R-*.asy %R-*_0.eps %R-*.pre";') latexmkrc.close() @@ -296,8 +303,8 @@ def nettoyage(basefilename): #try: # os.remove('latexmkrc') #except OSError: - # pass - if os.path.getsize('%s.pdf' % basefilename) > 1000 : + # pass) + if os.path.getsize('{}.pdf'.format(basefilename)) > 1000 : for ext in ('.log', '-pyromaths.log'): try: os.remove(basefilename + ext) diff --git a/src/pyromaths/outils/TestEnv.py b/src/pyromaths/outils/TestEnv.py index eae0e485..19dbb151 100644 --- a/src/pyromaths/outils/TestEnv.py +++ b/src/pyromaths/outils/TestEnv.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -30,6 +30,7 @@ # lecture de pyromaths.xml # écriture dans le dossier de destination +from __future__ import unicode_literals from os.path import isfile, join def test(gui): diff --git a/src/pyromaths/outils/TexFiles.py b/src/pyromaths/outils/TexFiles.py index b49f7887..a18a3c02 100644 --- a/src/pyromaths/outils/TexFiles.py +++ b/src/pyromaths/outils/TexFiles.py @@ -19,6 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import print_function +from __future__ import unicode_literals +from builtins import range import codecs def mise_en_forme(file): """ @@ -44,7 +47,7 @@ def mise_en_forme(file): cline = cline.strip() indent = trouve_indentation(cline, indent, lline) if indent < 0: - print _(u"problème") + print(_(u"problème")) if cline: chaine, indent = traite_chaine(cline, indent) new_tex.extend(chaine) diff --git a/src/pyromaths/outils/__init__.py b/src/pyromaths/outils/__init__.py index 214ed1f1..914a119e 100644 --- a/src/pyromaths/outils/__init__.py +++ b/src/pyromaths/outils/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths diff --git a/src/pyromaths/outils/decimaux.py b/src/pyromaths/outils/decimaux.py index b04664c0..2e2377fc 100644 --- a/src/pyromaths/outils/decimaux.py +++ b/src/pyromaths/outils/decimaux.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -21,6 +21,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import unicode_literals +from builtins import str import re def suppr0(nombre): @@ -69,4 +71,4 @@ def decimaux(nb, mathenv=0): return ",".join(("\,".join(partie_entiere), "\,".join(partie_decimale))) else: - return "\,".join(partie_entiere) \ No newline at end of file + return "\,".join(partie_entiere) diff --git a/src/pyromaths/outils/jinja2.py b/src/pyromaths/outils/jinja2.py index aaef6d06..a4f82023 100644 --- a/src/pyromaths/outils/jinja2.py +++ b/src/pyromaths/outils/jinja2.py @@ -23,7 +23,10 @@ """Outils à utiliser avec les exercices utilisant Jinja2. """ +from __future__ import unicode_literals +from builtins import str +from builtins import range import math import numbers diff --git a/src/pyromaths/pyromaths.py b/src/pyromaths/pyromaths.py index c8cadf90..92e508a1 100755 --- a/src/pyromaths/pyromaths.py +++ b/src/pyromaths/pyromaths.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Pyromaths @@ -20,6 +20,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import unicode_literals import gettext from sys import argv, exit import sys @@ -35,18 +37,18 @@ def main(): locale_dir = join(dirname(__file__), '../../locale/') locale_dir = realpath(locale_dir) - gettext.install('pyromaths', localedir=locale_dir, unicode=1) + gettext.install('pyromaths', localedir=locale_dir) - from outils.System import create_config_file, modify_config_file - from outils.TestEnv import test - from Values import CONFIGDIR + from .outils.System import create_config_file, modify_config_file + from .outils.TestEnv import test + from .Values import CONFIGDIR - import interface - from PyQt4 import QtGui - class StartQT4(QtGui.QMainWindow, interface.Ui_MainWindow): + from . import interface + from PyQt5 import QtGui, QtWidgets + class StartQT4(QtWidgets.QMainWindow, interface.Ui_MainWindow): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.ui = interface.Ui_MainWindow() self.ui.setupUi(self) @@ -64,11 +66,11 @@ def __init__(self, parent=None): packagesdir = join(CONFIGDIR, "packages") if not isdir(packagesdir): makedirs(packagesdir) - app = QtGui.QApplication(argv) + app = QtWidgets.QApplication(argv) pyromaths = StartQT4() # Intégration de QTranslator - from PyQt4.QtCore import QTranslator + from PyQt5.QtCore import QTranslator translator = QTranslator() translator.load("qtmac_fr", "data") app.installTranslator(translator) diff --git a/src/test/test_exercices_names.py b/src/test/test_exercices_names.py index 2e19fb9b..164227f4 100644 --- a/src/test/test_exercices_names.py +++ b/src/test/test_exercices_names.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals import unittest import pyromaths diff --git a/utils/creer-vignettes.py b/utils/creer-vignettes.py index 31560b7c..7f2f657e 100755 --- a/utils/creer-vignettes.py +++ b/utils/creer-vignettes.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # pylint: disable=invalid-name diff --git a/utils/pyromaths-cli.py b/utils/pyromaths-cli.py index e7d8171d..cfded945 100755 --- a/utils/pyromaths-cli.py +++ b/utils/pyromaths-cli.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright Louis Paternault 2018