Example #1
0
 def test_division_negative_decimal(self):
     self.assertAlmostEqual(m.division(7813, -2718924),
                            -0.0028735632183908045977011494)
     self.assertAlmostEqual(m.division(-22329857.546546, -284639.65213),
                            78.449567301844355300013)
     self.assertAlmostEqual(m.division(41.54584512318978795, -5.5648956321),
                            -7.465700683322935297354)
Example #2
0
 def test_division_positive_decimal(self):
     self.assertAlmostEqual(m.division(8, 128), 0.0625)
     self.assertAlmostEqual(m.division(248.548794, 7008.24556448),
                            0.0354651947785225618424561771414)
     self.assertAlmostEqual(
         m.division(12818713496123908905.5484564, 546489789.31564),
         23456455631.452087845024528706421)
Example #3
0
 def test_division_negative_whole(self):
     self.assertEqual(m.division(-2718924, 7813), -348,
                      "Expected solution: -348")
     self.assertEqual(m.division(-22333629857, -284639), 78463,
                      "Expected solution: 78463")
     self.assertEqual(m.division(41036151960494831322, -523975123),
                      -78316985214, "Expected solution: -78 316 985 214")
Example #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
Example #5
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 #6
0
 def test_division_zero(self):
     self.assertEqual(m.division(1, 0), None,
                      "Expected solution: None -> Can't divide with zero")
     self.assertEqual(m.division(-8, 0), None,
                      "Expected solution: None -> Can't divide with zero")
Example #7
0
 def test_division_positive_whole(self):
     self.assertEqual(m.division(128, 8), 16, "Expected solution: 16")
     self.assertEqual(m.division(6385008, 248), 25746,
                      "Expected solution: 25 746")
     self.assertEqual(m.division(12818713496123908905, 546489789),
                      23456455645, "Expected solution: 23 456 455 645")