Beispiel #1
0
 def test_mulEqualNegativeNegative(self):
     #negative number & negative number
     assert m.multiplication(-5, -1) == 5
     assert m.multiplication(-3, -7) == 21
     assert m.multiplication(-43, -5) == 215
     assert m.multiplication(-3, -98) == 294
     assert m.multiplication(-75, -28) == 2100
     assert m.multiplication(-69, -55) == 3795
     assert m.multiplication(-423, -30) == 12690
     assert m.multiplication(-6, -666) == 3996
     assert m.multiplication(-485, -608) == 294880
     assert m.multiplication(-5034, -7837) == 39451458
Beispiel #2
0
 def test_mulNotEqualNegativeNegative(self):
     #negative number & negative number
     assert m.multiplication(-3, -9) != 0
     assert m.multiplication(-1, -5) != -5
     assert m.multiplication(-4, -8) != 98
     assert m.multiplication(-18, -7) != -40
     assert m.multiplication(-36, -89) != 3689
     assert m.multiplication(-328, -2) != -403
     assert m.multiplication(-532, -439) != 903320
     assert m.multiplication(-4345, -6821) != -28333745
     assert m.multiplication(-73923, -4) != -38392
Beispiel #3
0
 def test_mulNotEqualPositiveNegative(self):
     #positive number & negative number
     assert m.multiplication(0, -5) != 8
     assert m.multiplication(-22, 0) != 42
     assert m.multiplication(4, -8) != -31
     assert m.multiplication(25, -3) != 75
     assert m.multiplication(80, -80) != -1616
     assert m.multiplication(-71, 993) != 73922
     assert m.multiplication(441, -2) != -655
     assert m.multiplication(232, -391) != -74583
     assert m.multiplication(-9563, -3068) != 392702
Beispiel #4
0
 def test_mulNotEqualPositivePositive(self):
     #positive number & positive number
     assert m.multiplication(0, 0) != 8
     assert m.multiplication(53, 0) != 53
     assert m.multiplication(0, 679) != 3
     assert m.multiplication(4, 3) != 231
     assert m.multiplication(76, 9) != 83
     assert m.multiplication(45, 20) != 50
     assert m.multiplication(653, 788) != 89043
     assert m.multiplication(502, 3) != 10001
     assert m.multiplication(3904, 2200) != 7849027
Beispiel #5
0
 def test_mulEqualPositiveNegative(self):
     #positive number & negative number
     assert m.multiplication(-5, 0) == 0
     assert m.multiplication(0, -45) == 0
     assert m.multiplication(-5, 12) == -60
     assert m.multiplication(7, -43) == -301
     assert m.multiplication(-76, 97) == -7372
     assert m.multiplication(-56, 38) == -2128
     assert m.multiplication(92, -111) == -10212
     assert m.multiplication(-6574, 3759) == -24711666
Beispiel #6
0
 def test_mulEqualPositivePositive(self):
     #positive number & positive number
     assert m.multiplication(0, 0) == 0
     assert m.multiplication(0, 67) == 0
     assert m.multiplication(9855, 0) == 0
     assert m.multiplication(3, 4) == 12
     assert m.multiplication(13, 6) == 78
     assert m.multiplication(55, 23) == 1265
     assert m.multiplication(647, 87) == 56289
     assert m.multiplication(7472, 954) == 7128288
Beispiel #7
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()
Beispiel #8
0
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