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
def test_solve_problem_with_int_result(problem, result): assert MathLib.solve_mathematic_problem(problem) == result
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
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
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
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
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
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
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
def test_bad_input_values(problem): result_of_mathlib = MathLib.solve_mathematic_problem(problem) assert result_of_mathlib is None
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
def test_wrong_input(problem): result_of_mathlib = MathLib.transform_string_to_postfix(problem) assert result_of_mathlib is None
def test_stringToPostfix_conversion(problem, result): assert MathLib.transform_string_to_postfix(problem) == result
def GetAritmeticMean(sum, n): oneDevidedN = MathLib.solve_mathematic_problem("1 /" + str(n)) aritMean = MathLib.solve_mathematic_problem(str(oneDevidedN) + "*" + str(sum)) return str(aritMean)