Пример #1
0
 def test_exponencial_correct_negative_decimal(self):
     self.assertAlmostEqual(m.exponencial(-18.4896, 6),
                            39954444.3220161036302421023)
     self.assertAlmostEqual(m.exponencial(-8.1236, 5),
                            -35378.7638681105623096)
     self.assertAlmostEqual(m.exponencial(1.57896325, 30),
                            893636.0097822846751274003235)
Пример #2
0
 def test_exponencial_correct_positive_decimal(self):
     self.assertAlmostEqual(m.exponencial(45.78512, 4),
                            4394378.155480441923306127)
     self.assertAlmostEqual(m.exponencial(5.7854545612, 7),
                            216951.37601471197541142619333761)
     self.assertAlmostEqual(m.exponencial(1.54878465465465, 12),
                            190.498887598528009755207019)
Пример #3
0
 def test_exponencial_incorrect(self):
     self.assertEqual(
         m.exponencial(12, 0.5), None,
         "Expected solution: None -> Function works only with natural exponents"
     )
     self.assertEqual(m.exponencial(0, 0), None,
                      "Expected solution: None -> It is undefined")
     self.assertEqual(
         m.exponencial(2, -2), None,
         "Expected solution: None -> Function works only with natural exponents"
     )
Пример #4
0
    def eq_pressed(self):
        x2 = float(self.result.text())

        if self.pushButton_add.isChecked():
            result_label = format(m.addition(self.x1, x2), '.15g')
            self.pushButton_add.setChecked(False)

        elif self.pushButton_sub.isChecked():
            result_label = format(m.substraction(self.x1, x2), '.15g')
            self.pushButton_sub.setChecked(False)

        elif self.pushButton_mul.isChecked():
            result_label = format(m.multiplication(self.x1, x2), '.15g')
            self.pushButton_mul.setChecked(False)

        elif self.pushButton_div.isChecked():
            if m.division(self.x1, x2) is None:
                result_label = "Undefined"
            else:
                result_label = format(m.division(self.x1, x2), '.15g')
            self.pushButton_div.setChecked(False)

        elif self.pushButton_mod.isChecked():
            if m.modulo(self.x1, x2) is None:
                result_label = "Undefined"
            else:
                result_label = format(m.modulo(self.x1, x2), '.15g')
            self.pushButton_mod.setChecked(False)

        elif self.pushButton_root.isChecked():
            if m.root(self.x1, x2) is None:
                result_label = "Undefined"
            else:
                result_label = format(m.root(self.x1, x2), '.15g')
            self.pushButton_root.setChecked(False)

        elif self.pushButton_power.isChecked():
            if m.exponencial(self.x1, x2) is None:
                result_label = "Undefined"
            else:
                result_label = format(m.exponencial(self.x1, x2), '.15g')
            self.pushButton_power.setChecked(False)
        else:
            result_label = self.result.text()
        self.result.setText(result_label)
        self.x2_type = False
Пример #5
0
 def test_exponencial_correct_negative_whole(self):
     self.assertEqual(m.exponencial(-5, 4), 625, "Expected solution: 625")
     self.assertEqual(m.exponencial(-127, 5), -33038369407,
                      "Expected solution: -33 038 369 407")
     self.assertEqual(m.exponencial(-79135546879875646, 0), 1,
                      "Expected solution: 1")
Пример #6
0
 def test_exponencial_correct_positive_whole(self):
     self.assertEqual(m.exponencial(12, 5), 248832,
                      "Expected solution: 248 832")
     self.assertEqual(m.exponencial(1, 2000), 1, "Expected solution: 1")
     self.assertEqual(m.exponencial(12456879875646546545123, 0), 1,
                      "Expected solution: 1")