2013-2014/3e/DM/DM_140129/rd_sqrt.py

55 lines
1.6 KiB
Python

#!/usr/bin/env python
# encoding: utf-8
from random_expression import RdExpression
square = RdExpression("{a**2}",\
conditions = ["{a} not in [-1,1]"],\
with_Exp = False)
squareDiv = RdExpression("{a**2/100}",\
conditions = ["{a} not in [-1,1]"],\
with_Exp = False)
sqrtXsqrt = RdExpression("\\sqrt{{ {a} }} \\times \\sqrt{{ {b} }}",\
conditions = ["{a} > 1","{a} not in [i**2 for i in range(10)]",\
"{b} > 1", "{b} not in [i**2 for i in range(10)]"],\
with_Exp = False)
intXsqrt = RdExpression("{a} \\times \\sqrt{{ {b} }}",\
conditions = ["{a} > 1", \
"{b} > 1", "{b} not in [i**2 for i in range(10)]"],\
with_Exp = False)
sqrtIsqrt = RdExpression("\\frac{{ \\sqrt{{ {a} }} }}{{ \\sqrt{{ {b} }} }}",\
conditions = ["{a} > 1","{a} not in [i**2 for i in range(10)]",\
"{b} > 1", "{b} not in [i**2 for i in range(10)]"],\
with_Exp = False)
sqrt1 = RdExpression("\\sqrt{{ {a**2 * b} }}",\
conditions = ["{a} > 1",\
"{b} > 1", "{b} not in [i**2 for i in range(10)]"],\
with_Exp = False)
intXsqrt2 = lambda *a, **k: int1(*a, **k) + " \\times " +sqrt1(*a, **k)
int1 = RdExpression("{a}", conditions = ["a > 1"], with_Exp = False)
sqrt = {"square" : square,\
"squareDiv" : squareDiv,\
"sqrtXsqrt": sqrtXsqrt,\
"intXsqrt": intXsqrt,\
"sqrtIsqrt":sqrtIsqrt,\
"sqrt1": sqrt1,\
"intXsqrt2": intXsqrt2,\
"int1": int1}
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del