2013-2014/4e/DS/4eC/04_dev/exercices.py

63 lines
1.6 KiB
Python
Raw Normal View History

2017-06-16 06:46:40 +00:00
#!/usr/bin/env python
# encoding: utf-8
from random_expression import RdExpression
def red_prod():
form1 = "{a}x \\times {b}"
cond1 = ["{a} != 1", "{b} > 1"]
rdExp1 = RdExpression(form1, cond1, with_Exp = False)
exp1 = rdExp1()
form2 = "{a}x \\times {b}x"
cond2 = ["{a} != 1", "{b} > 1"]
rdExp2 = RdExpression(form2, cond2, with_Exp = False)
exp2 = rdExp2()
ans = exp1 + "= \\parbox{1cm}{\\dotfill} \\hspace{2cm} " + exp2 + "= \\parbox{1cm}{\\dotfill}"
return ans
def red_somme():
form1 = "{a}x + {b} + {c}x"
cond1 = ["{a} != 1","{c} > 1"]
rdExp1 = RdExpression(form1, cond1, with_Exp = False)
exp1 = rdExp1()
form2 = "{a}x + {b} + {c}x"
cond2 = ["{a} != 1","{c} > 1"]
rdExp2 = RdExpression(form2, cond2, with_Exp = False)
exp2 = rdExp2()
ans = exp1 + " = \\parbox{3cm}{\\dotfill} = \\parbox{2cm}{\\dotfill} \\\\[0.5cm]"
ans += exp2 + " = \\parbox{3cm}{\\dotfill} = \\parbox{2cm}{\\dotfill} \\\\[0.5cm]"
return ans
def simple_prod():
form = "{a}({b}x + {c})"
cond = ["{a} != 1", "{b} != 1", "{c} > 1"]
rdExp = RdExpression(form, cond, with_Exp = False)
return rdExp()
def double_prod():
form = "({a}x - {d})({b}x + {c})"
cond = ["{a} != 1", "{b} != 1", "{d} > 1", "{c} > 1"]
rdExp = RdExpression(form, cond, with_Exp = False)
return rdExp()
def carre_prod():
form = "({a}x + {d})^2"
cond = ["{a} != 1", "{d} > 1"]
rdExp = RdExpression(form, cond, with_Exp = False)
return rdExp()
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del