def test_powNotEqualNegativeNegative(self): #negative number & negative number assert m.power(-1, -1) != -2 assert m.power(-3, -3) != -9 assert m.power(-23, -1) != -0.5333 assert m.power(-6, -3) != -0.000005 assert m.power(-2, -13) != -0.0353638 assert m.power(-43, -5) != -0.6373223 assert m.power(-5, -2) != 10 assert m.power(-74, -2) != -321321
def test_powNotEqualPositiveNegative(self): #positive number & negative number assert m.power(3, -1) != 0.5332 assert m.power(6, -6) != -0.4321 assert m.power(23, -1) != 0.64893 assert m.power(5, -4) != 2.445 assert m.power(32, -3) != -4583 assert m.power(66, -2) != -0.6892 assert m.power(4, -3) != 0.1124 assert m.power(86, -7) != 933
def test_powNotEqualNegativePositive(self): #negative number & positive number assert m.power(-4, 5) != -20 assert m.power(-7, 2) != 50 assert m.power(-34, 0) != -1 assert m.power(-4, 2) != -16 assert m.power(-84, 4) != -5432123 assert m.power(-643, 0) != -643 assert m.power(-45, 3) != 632 assert m.power(-6325, 1) != 6325
def test_powEqualNegativeNegative(self): #negative number & negative number assert m.power(-1, -1) == -1 assert m.power(-1, -89) == -1 assert m.power(-2, -3) == -0.125 assert m.power(-20, -2) == 0.0025 assert m.power(-4, -2) == 0.0625 assert m.power(-8, -1) == -0.125 assert m.power(-5, -2) == 0.04 assert m.power(-5, -1) == -0.2
def test_powNotEqualPositivePositive(self): #positive number & positive number assert m.power(0, 0) != 3 assert m.power(0, 2) != 1 assert m.power(21, 0) != 21 assert m.power(50, 5) != 55 assert m.power(23, 2) != 675 assert m.power(652, 1) != 1000 assert m.power(17, 8) != 34533346 assert m.power(84, 5) != 689239
def test_powEqualNegativePositive(self): #negative number & positive number assert m.power(-2, 0) == 1 assert m.power(-3, 2) == 9 assert m.power(-7, 4) == 2401 assert m.power(-5, 1) == -5 assert m.power(-14, 2) == 196 assert m.power(-22, 3) == -10648 assert m.power(-5, 4) == 625 assert m.power(-15, 3) == -3375
def test_powEqualPositiveNegative(self): #positive number & negative number assert m.power(0, -3) == "Invalid input" assert m.power(2, -2) == 0.25 assert m.power(20, -1) == 0.05 assert m.power(5, -4) == 0.0016 assert m.power(1, -5) == 1 assert m.power(4, -6) == 0.000244140625 assert m.power(2, -3) == 0.125 assert m.power(8, -2) == 0.015625
def test_powEqualPositivePositive(self): #positive number & positive number assert m.power(0, 0) == 1 assert m.power(5, 0) == 1 assert m.power(7, 2) == 49 assert m.power(3, 5) == 243 assert m.power(0, 27) == 0 assert m.power(35, 4) == 1500625 assert m.power(123, 1) == 123 assert m.power(609, 3) == 225866529
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