mathmaker
0.6(alpha)
|
00001 # -*- coding: utf-8 -*- 00002 00003 # Mathmaker creates automatically maths exercises sheets 00004 # with their answers 00005 # Copyright 2006-2014 Nicolas Hainaux <nico_h@users.sourceforge.net> 00006 00007 # This file is part of Mathmaker. 00008 00009 # Mathmaker is free software; you can redistribute it and/or modify 00010 # it under the terms of the GNU General Public License as published by 00011 # the Free Software Foundation; either version 3 of the License, or 00012 # any later version. 00013 00014 # Mathmaker is distributed in the hope that it will be useful, 00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 # GNU General Public License for more details. 00018 00019 # You should have received a copy of the GNU General Public License 00020 # along with Mathmaker; if not, write to the Free Software 00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 import os 00024 import sys 00025 00026 from core import * 00027 from core.base_calculus import * 00028 00029 from maintenance.autotest import common 00030 00031 check = common.check 00032 00033 00034 def action(): 00035 if common.verbose: 00036 os.write(common.output, bytes("--- FRACTIONS QUOTIENTS\n", 'utf-8')) 00037 00038 div_fraction_9over3_by_fraction_1overminus3 = \ 00039 Quotient(('+', 00040 Fraction(('+', Item(9), Item(3))), 00041 Fraction(('+', Item(1), Item(-3))) 00042 )) 00043 00044 div_fraction_9over3_by_fraction_1overminus3.set_symbol('use_divide_symbol') 00045 00046 00047 #check(fraction_minus3timesminus1_over_minus2times9.simplification_line(), 00048 # ["essai"]) 00049 step_1 = div_fraction_9over3_by_fraction_1overminus3.calculate_next_step() 00050 check(step_1, 00051 ["\\frac{9}{3}\\times \\frac{-3}{1}"]) 00052 00053 step_2 = step_1.calculate_next_step() 00054 check(step_2, 00055 ["-\\frac{9\\times 3}{3\\times 1}"]) 00056 step_3 = step_2.calculate_next_step() 00057 check(step_3, 00058 ["-\\frac{9\\times \\bcancel{3}}{\\bcancel{3}}"]) 00059 step_4 = step_3.calculate_next_step() 00060 check(step_4, 00061 ["-9"]) 00062 step_5 = step_4.calculate_next_step() 00063 check(step_5, 00064 ["None"]) 00065 00066 00067 00068 00069