def test_divNotEqualNegativeNegative(self): #negative number & negative number assert m.divide(-25, -5) != -5 assert m.divide(-32, -8) != 155 assert m.divide(-72, -6) != 13 assert m.divide(-121, -11) != -11 assert m.divide(-13952, -4) != 45668 assert m.divide(-156468, -5612) != 468412 assert m.divide(-4532, -1133) != -4 assert m.divide(-332688, -348) != -956 assert m.divide(-5943456, -4586) != 1300
def test_divNotEqualPositivePositive(self): #postive number & positive number assert m.divide(12, 2) != 8 assert m.divide(90, 3) != 15 assert m.divide(15, 5) != 4 assert m.divide(6, 3) != 1 assert m.divide(225, 15) != 14 assert m.divide(333, 3) != 100 assert m.divide(1024, 256) != 5 assert m.divide(1568, 4) != 393 assert m.divide(177152, 346) != 500
def test_divNotEqualPositiveNegative(self): #positive number & negative number assert m.divide(-12, 4) != 3 assert m.divide(18, -6) != 3 assert m.divide(25, -25) != 0 assert m.divide(56, -7) != 8 assert m.divide(234, -2) != -116 assert m.divide(-81, 9) != 9 assert m.divide(169, -13) != 13 assert m.divide(-1200, 4) != 300 assert m.divide(392702, -3068) != 9563
def test_divEqualNegativeNegative(self): #negative number & negative number assert m.divide(-5, -5) == 1 assert m.divide(-14, -7) == 2 assert m.divide(-35, -7) == 5 assert m.divide(-81, -3) == 27 assert m.divide(-144, -6) == 24 assert m.divide(-256, -4) == 64 assert m.divide(-17848, -92) == 194 assert m.divide(-177152, -512) == 346 assert m.divide(-297416, -452) == 658
def test_divEqualPositiveNegative(self): #positive number & negative number assert m.divide(6, -3) == -2 assert m.divide(28, -7) == -4 assert m.divide(12, -2) == -6 assert m.divide(-18, 6) == -3 assert m.divide(-64, 8) == -8 assert m.divide(-110, 5) == -22 assert m.divide(294, -14) == -21 assert m.divide(3509, -121) == -29 assert m.divide(-37730, 154) == -245
def test_divEqualPositivePositive(self): #positive number & positive number assert m.divide(10, 5) == 2 assert m.divide(15, 3) == 5 assert m.divide(21, 7) == 3 assert m.divide(32, 4) == 8 assert m.divide(99, 3) == 33 assert m.divide(1152, 18) == 64 assert m.divide(0, 14568) == 0 assert m.divide(119658, 231) == 518 assert m.divide(2, 0) == "Invalid input"
def equalClick(self): """ Funkcia na vyhodnotenie zadaného príkladu v kalkulačke. Volá funkcie z matematickej knižnice mathlib.py """ global operatorFlag global operator global leftSide global rightSide global errorFlag global leftSideValue global rightSideValue rightSideValue = SideValue(rightSide) leftSideValue = SideValue(leftSide) result = "" if errorFlag: result = "Invalid input" else: if not leftSide: result = "Invalid input" #calling functions from mathlib based on operator value elif '!' in operator: result = m.factorial(leftSideValue) elif not rightSide: result = "Invalid input" elif '+' in operator: result = m.add(leftSideValue, rightSideValue) elif '-' in operator: result = m.subtraction(leftSideValue, rightSideValue) elif '*' in operator: result = m.multiplication(leftSideValue, rightSideValue) elif '/' in operator: result = m.divide(leftSideValue, rightSideValue) elif '^' in operator: result = m.power(leftSideValue, rightSideValue) elif '\u221A' in operator: #root symbol result = m.nthRoot(leftSideValue, rightSideValue) elif '%' in operator: result = m.modulo(leftSideValue, rightSideValue) if not operator and leftSide and not rightSide: # if user inserted only one number without operator result = leftSideValue self.ui.resultDisplay.setText(str(result)) clearEverything()
def Standard_deviation(): """ Funkcia na výpočet smerodajnej odchýlky zo štandardného vstupu(stdin) :return: výslednú smerodajnú odchýlku pre zadané čísla """ global N sumSX = 0 sumSX2 = 0 for line in sys.stdin: strip = int(line.rstrip()) N = m.add(N, 1) sumSX = m.add(sumSX, strip) sumSX2 = m.add(sumSX2, m.power(strip, 2)) x_line = m.multiplication(m.divide(1, N), sumSX) multInBracket = m.multiplication(N, m.power(x_line, 2)) bracket = m.subtraction(sumSX2, multInBracket) leftSide = m.divide(1, m.subtraction(N, 1)) multOutBracket = m.multiplication(leftSide, bracket) result = m.nthRoot(2, multOutBracket) return result