Example #1
0
 def test_substraction_negative_whole(self):
     self.assertEqual(m.substraction(-20, -50), 30, "Expected solution: 30")
     self.assertEqual(m.substraction(120, -158), 278,
                      "Expected solution: 278")
     self.assertEqual(m.substraction(-7546467564540,
                                     -5546455450), -7540921109090,
                      "Expected solution: -7 540 921 109 090")
Example #2
0
 def test_substraction_positive_decimal(self):
     self.assertEqual(m.substraction(1.5, 7.125), -5.625,
                      "Expected solution: -5,625")
     self.assertEqual(m.substraction(0.124578, 1454.15454525),
                      -1454.02996725, "Expected solution: -1454.02996725")
     self.assertEqual(
         m.substraction(4545.545654564556455, 457.154564564564525),
         4088.39108999999193, "Expected solution: 4 088,39108999999193")
Example #3
0
 def test_substraction_negative_decimal(self):
     self.assertEqual(m.substraction(-71.5, -227.125), 155.625,
                      "Expected solution: 155,625")
     self.assertEqual(m.substraction(-45.78756456, 17.15454625),
                      -62.94211081, "Expected solution: -62,94211081")
     self.assertEqual(
         m.substraction(75.5456456744564, -877.15454654654655425),
         952.70019222100295425, "Expected solution: 952,70019222100295425")
Example #4
0
def calculate_result():
    global amount, sum_normal, sum_square, result

    sum_normal = m.multiplication(sum_normal,
                                  (m.division(1, amount)))  # 1/N * (sum x)

    result = m.multiplication(sum_normal, sum_normal)  # x^2
    result = m.multiplication(result, amount)  # N*x^2

    result = m.substraction(sum_square, result)  # (sum (xi^2)) - (N*x^2)

    help = m.substraction(amount, 1)  # N - 1
    help = m.division(1, help)  # 1/(N-1)

    result = m.multiplication(help,
                              result)  # (1/(N-1)) * ((sum (xi^2)) - (N*x^2))
    result = m.root(2, result)
Example #5
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
Example #6
0
 def test_substraction_positive_whole(self):
     self.assertEqual(m.substraction(25, 30), -5, "Expected solution: -5")
     self.assertEqual(m.substraction(250, 120), 130,
                      "Expected solution: 130")
     self.assertEqual(m.substraction(2700256, 250785121), -248084865,
                      "Expected solution:-248 084 865")