2018-01-21 08:26:34 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim:fenc=utf-8
|
|
|
|
#
|
|
|
|
# Copyright © 2017 lafrite <lafrite@Poivre>
|
|
|
|
#
|
|
|
|
# Distributed under terms of the MIT license.
|
|
|
|
|
|
|
|
"""
|
2018-03-10 05:44:01 +00:00
|
|
|
Make calculus as a student
|
2019-05-08 12:44:35 +00:00
|
|
|
==========================
|
|
|
|
|
|
|
|
Expression is the classe wich handle all calculus. It can randomly generate or import calculus, simplify them and explain them as a student would do.
|
|
|
|
|
2020-12-15 14:37:27 +00:00
|
|
|
>>> render.set_render("txt")
|
2019-05-08 12:44:35 +00:00
|
|
|
>>> e = Expression.from_str("2x + 6 - 3x")
|
|
|
|
>>> print(e)
|
|
|
|
2x + 6 - 3x
|
|
|
|
>>> f = e.simplify()
|
|
|
|
>>> print(f)
|
|
|
|
- x + 6
|
|
|
|
>>> for s in f.explain():
|
|
|
|
... print(s)
|
|
|
|
2x + 6 - 3x
|
|
|
|
2x - 3x + 6
|
|
|
|
(2 - 3) * x + 6
|
|
|
|
- x + 6
|
|
|
|
|
2021-10-09 13:22:58 +00:00
|
|
|
Create random Expression
|
|
|
|
========================
|
|
|
|
|
|
|
|
>>> e = random.expression("{a} / {b} + {c} / {d}")
|
|
|
|
>>> print(e) # doctest: +SKIP
|
|
|
|
- 3 / - 10 + 3 / 5
|
2019-05-08 12:44:35 +00:00
|
|
|
|
2018-01-21 08:26:34 +00:00
|
|
|
"""
|
|
|
|
|
2021-10-09 13:22:58 +00:00
|
|
|
from .API import render, Expression
|
|
|
|
#from decimal import getcontext
|
|
|
|
from . import random
|
|
|
|
|
2019-10-15 17:41:09 +00:00
|
|
|
#getcontext().prec = 2
|
|
|
|
|
2019-05-08 12:44:35 +00:00
|
|
|
|
2021-10-09 13:22:58 +00:00
|
|
|
__all__ = ["render", "Expression", "random"]
|
2016-01-07 16:34:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------
|
|
|
|
# Reglages pour 'vim'
|
|
|
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
2016-02-13 03:29:26 +00:00
|
|
|
# cursor: 16 del
|