1 | #!/usr/bin/python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | # |
---|
4 | # Pyromaths |
---|
5 | # Un programme en Python qui permet de créer des fiches d'exercices types de |
---|
6 | # mathématiques niveau collège ainsi que leur corrigé en LaTeX. |
---|
7 | # Copyright (C) 2015 -- Jérôme Ortais (jerome.ortais@pyromaths.org) |
---|
8 | # |
---|
9 | # This program is free software; you can redistribute it and/or modify |
---|
10 | # it under the terms of the GNU General Public License as published by |
---|
11 | # the Free Software Foundation; either version 2 of the License, or |
---|
12 | # (at your option) any later version. |
---|
13 | # |
---|
14 | # This program is distributed in the hope that it will be useful, |
---|
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | # GNU General Public License for more details. |
---|
18 | # |
---|
19 | # You should have received a copy of the GNU General Public License |
---|
20 | # along with this program; if not, write to the Free Software |
---|
21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | # |
---|
23 | |
---|
24 | from pyromaths import ex |
---|
25 | from random import randrange, shuffle |
---|
26 | from pyromaths.outils import Priorites3 |
---|
27 | from pyromaths.classes.Fractions import Fraction |
---|
28 | from pyromaths.classes.PolynomesCollege import Polynome |
---|
29 | from pyromaths.ex.lycee.SecondDegre import creerPolydegre2 |
---|
30 | from pyromaths.outils.Arithmetique import valeur_alea |
---|
31 | |
---|
32 | class Fd6DeriveeEtVariations(ex.TexExercise): |
---|
33 | ''' |
---|
34 | classdocs |
---|
35 | ''' |
---|
36 | #description = u'Dérivée et sens de variation d’une fonction' |
---|
37 | #level = u"1.1èreS" |
---|
38 | |
---|
39 | |
---|
40 | def __init__(self): |
---|
41 | der = [creerPolydegre2(0), creerPolydegre2(1, False), creerPolydegre2(2, False)] |
---|
42 | n = randrange(1,5) |
---|
43 | der.append(Polynome([[valeur_alea(-9, 9), n+1],[valeur_alea(-9, 9), n]])) |
---|
44 | pol = [] |
---|
45 | for p in der: |
---|
46 | pol.append(p.primitive()+Polynome('%s' % randrange(-9, 10))) |
---|
47 | shuffle(pol) |
---|
48 | self.exercice = pol |
---|
49 | |
---|
50 | def tex_statement(self): |
---|
51 | exo = [r'\exercice'] |
---|
52 | exo.append(r'\setlength{\abovedisplayskip}{-1.5ex}') |
---|
53 | exo.append(_(u'Dresser le tableau de variations de chacune des fonctions suivantes.\\par')) |
---|
54 | |
---|
55 | exo.append('\\begin{align*}') |
---|
56 | noms = [r'f\,(x) &= ', r'g\,(x) &= ', r'h\,(x) &= ', r'i\,(x) &= '] |
---|
57 | r = [] |
---|
58 | for i in range(3): |
---|
59 | r.append(noms[i] + str(self.exercice[i])) |
---|
60 | |
---|
61 | exo.append(' &\n'.join(r)) |
---|
62 | exo.append('\\end{align*}') |
---|
63 | return exo |
---|