Ejemplo n.º 1
0
def GetStandardDeviation():
    listFromFile = []
    if __name__ == "__main__":
        data = input()
        listFromFile = data.split(" ")
    n = len(listFromFile)
    sum = MathLib.solve_mathematic_problem(GetSum(listFromFile, "1"))
    oneDevidedNMinusOne = str(MathLib.solve_mathematic_problem("1 /" + str(n - 1)))
    sumSquared = str(MathLib.solve_mathematic_problem(GetSum(listFromFile, "2")))
    aritMean = str(MathLib.solve_mathematic_problem(GetAritmeticMean(sum, n) + " ^ 1"))
    aritMeanSquared = str(MathLib.solve_mathematic_problem(aritMean + " ^ 2"))
    bracket = str(
        MathLib.solve_mathematic_problem(
            sumSquared
            + " - "
            + str(n)
            + " * "
            + aritMeanSquared))
    underSquareRoot = str(MathLib.solve_mathematic_problem(oneDevidedNMinusOne + " * " + bracket))
    standardDeviation = MathLib.solve_mathematic_problem(underSquareRoot + "_2")

    return standardDeviation
Ejemplo n.º 2
0
def test_solve_problem_with_int_result(problem, result):
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 3
0
def test_advance_math_problem_1():
    problem = "((44*(32+12)^2)_2)+2*3+3"
    result = 300.8629816
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 4
0
def test_advance_math_problem():
    problem = "1+(1/(1+(1/(1+(1/(1+(1/1)))))))"
    result = 1.6
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 5
0
def test_extream_power_1():
    nums = [str(i) for i in range(5, 8, 1)]
    problem = ")^".join(nums)
    problem = "(" * (len(nums) - 1) + problem
    result = 227373675443232059478759765625
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 6
0
def test_extream_power():
    nums = [str(i) for i in range(1, 200, 3)]
    problem = ")^".join(nums)
    problem = "(" * (len(nums) - 1) + problem
    result = 1
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 7
0
def test_extream_div():
    nums = [str(i) for i in range(1, 100, 3)]
    problem = "/".join(nums)
    result = 5.7290546601574706e-52
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 8
0
def test_extream_multi():
    nums = [str(i) for i in range(1, 100, 3)]
    problem = "*".join(nums)
    result = 1745488670154377397414943478973600699284193280000000
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 9
0
def test_extream_sub():
    nums = [str(i) for i in range(1, 10000, 3)]
    problem = "-".join(nums)
    result = -16661665
    assert MathLib.solve_mathematic_problem(problem) == result
Ejemplo n.º 10
0
def test_bad_input_values(problem):
    result_of_mathlib = MathLib.solve_mathematic_problem(problem)
    assert result_of_mathlib is None
Ejemplo n.º 11
0
def test_solve_problem_with_float_result(problem, result):
    result_of_mathlib = MathLib.solve_mathematic_problem(problem)
    assert (abs(result_of_mathlib) - abs(result)) <= EPSILON
Ejemplo n.º 12
0
def test_wrong_input(problem):
    result_of_mathlib = MathLib.transform_string_to_postfix(problem)
    assert result_of_mathlib is None
Ejemplo n.º 13
0
def test_stringToPostfix_conversion(problem, result):
    assert MathLib.transform_string_to_postfix(problem) == result
Ejemplo n.º 14
0
def GetAritmeticMean(sum, n):
    oneDevidedN = MathLib.solve_mathematic_problem("1 /" + str(n))
    aritMean = MathLib.solve_mathematic_problem(str(oneDevidedN) + "*" + str(sum))
    return str(aritMean)