Exemple #1
0
def calculate(expression):
    return polishrecord.polish(polishrecord.exptopolish(expression))
 def test_complex3(self):
     self.assertEqual(polish('-5 15 + 5 2 * -'), -5+15-5*2)
 def test_complex2(self):
     self.assertEqual(polish('2 15 5 - * 8 3 2 1 - * - /'), 2 * (15 - 5)/(8 - 3 * (2 - 1)))
 def test_complex1(self):
     self.assertEqual(polish('8 5 2 * + 2 3 * 1 + 4 - /'), (8+5*2)/(((2*3)+1)-4))
 def test_zero_divizion(self):
     self.assertEqual(polish('8 5 + 5 5 - /'), 'Error! Zero division!')
 def test_wrong_operands_number(self):
     self.assertEqual(polish('8 5 2 * + 2 3 * 1 + 4 - / *'), 'Error! Wrong numbers of operands')