def test_multiplication_positive_whole(self): self.assertEqual(m.multiplication(8, 5), 40, "Expected solution: 40") self.assertEqual(m.multiplication(45468, 0), 0, "Expected solution: 40") self.assertEqual(m.multiplication(85456487456, 55456465456), 4739114744594761319936, "Expected solution: 4 739 114 744 594 761 319 936")
def test_multiplication_positive_decimal(self): self.assertAlmostEqual(m.multiplication(25.86, 75.885), 1962.3861) self.assertAlmostEqual(m.multiplication(368752.896427, 0.5487865), 202366.6113950358355) self.assertEqual( m.multiplication(8547456.4787554211348, 5545656.35788561321564), 47401256365160.577082109313779873, "Expected solution: 47 401 256 365 160.577082109313779873")
def test_multiplication_negative_decimal(self): self.assertEqual(m.multiplication(-67.215, -97.853), 6577.189395, "Expected solution: 6 577,189395") self.assertEqual(m.multiplication(-81679.246795, 95546.75213489), -7804186748.08637344017755, "Expected solution: -7 804 186 748,08637344017755") self.assertAlmostEqual( m.multiplication(7.5452148784564, -2.74321548975465231), -20.698150328108862728653091494284)
def test_multiplication_negative_whole(self): self.assertEqual(m.multiplication(-80, -50), 4000, "Expected solution: 4 000") self.assertEqual(m.multiplication(-45468, 956), -43467408, "Expected solution: -43 467 408") self.assertEqual( m.multiplication(875648953123, -231268753215645), -202510241643340984115209335, "Expected solution: -202 510 241 643 340 984 115 209 335")
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)
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
def calculate_line(num): global amount, sum_normal, sum_square amount = m.addition(amount, 1) sum_normal = m.addition(sum_normal, num) sum_square = m.addition(sum_square, (m.multiplication(num, num)))