def test_addEqualPositivePositive(self): #positive number & positive number assert m.add(2, 3) == 5 assert m.add(5, 5) == 10 assert m.add(4, 8) == 12 assert m.add(0, 9) == 9 assert m.add(99, 0) == 99 assert m.add(56, 20) == 76 assert m.add(150, 70) == 220 assert m.add(10000, 2536) == 12536 assert m.add(1653, 752) == 2405
def test_addNotEqualPositiveNegative(self): #positive number & negative number assert m.add(-2, 311) != 111 assert m.add(-5, 80) != 40.45 assert m.add(10, -7) != 12 assert m.add(-12, 110) != -34.78 assert m.add(45, -5) != -13 assert m.add(-14, 51) != -9.65 assert m.add(-25, 125) != 0 assert m.add(100, -103564) != 0
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 test_addNotEqualPositivePositive(self): #positive number & positive number assert m.add(2, 4) != 2 assert m.add(70, 3) != -5 assert m.add(210, 18) != 17 assert m.add(10, 107) != -8.8 assert m.add(4, 111) != 100000 assert m.add(4025, 46555) != 0 assert m.add(1484910, 6515612) != 654589214
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
def test_addNotEqualNegativeNegative(self): #negative number & negative number assert m.add(-2, -3) != -2 assert m.add(-5, -1) != -27 assert m.add(-13, -7) != 87.7 assert m.add(-40, -11) != 0 assert m.add(-4025, -46555) != -44524 assert m.add(-1484910, -6515612) != 1001
def test_addEqualNegativeNegative(self): #negative number & negative number assert m.add(-2, -3) == -5 assert m.add(-5, -18) == -23 assert m.add(-1, -7) == -8 assert m.add(-4, -111) == -115 assert m.add(-4025, -46555) == -50580 assert m.add(-1484910, -6515612) == -8000522
def test_addEqualPositiveNegative(self): #positive number & negative number assert m.add(-2, 3) == 1 assert m.add(-5, 8) == 3 assert m.add(10, -7) == 3 assert m.add(-4, 1) == -3 assert m.add(4, -5) == -1 assert m.add(-14, 5) == -9 assert m.add(-25, 25) == 0 assert m.add(100, -100) == 0 assert m.add(-23, 77) == 54 assert m.add(120, -1700) == -1580 assert m.add(12302, -12123) == 179