예제 #1
0
def nArithmeticProblem():
    try:
        a = random.randint(10, 100)
        b = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        sol = b + (c * a)
        items = []
        for x in range(5):
            items.append(b + (c * (x + 1)))

        question = "The first five element of a series are " + str(
            items[0]) + "," + str(items[1]) + "," + str(items[2]) + "," + str(
                items[3]) + "," + str(
                    items[4]) + ", which is the value of the " + str(
                        a) + "th item?:"
        solution = str(sol)
        options = coursesFunctionsBll.arithmeticAlternatives(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
예제 #2
0
def simpleLimitProblem():
    try:
        a = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        b = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        solution = (2 * a) + b
        question = "[lim x->(" + str(a) + ")] for ((x^2)+(" + str(
            b) + "*x)+(" + str((-a * b) - (a**2)) + "))/(x-(" + str(a) + "))"
        options = coursesFunctionsBll.arithmeticAlternatives(solution)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
예제 #3
0
def simpleGaussProblem():
    try:
        a = random.randint(100, 1000)
        sol = (a + 1) * a / 2
        question = "use the gauss formula to get the sum of the natural numbers between 1 and " + str(
            a) + ":"
        solution = str(sol)
        options = coursesFunctionsBll.arithmeticAlternatives(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
예제 #4
0
def trigonometryLimitProblem():
    try:
        a = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        b = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        sol = round((b / c) + (1 / (c / a)), 4)
        solution = str(sol)
        question = "[lim x->(0)] for (sin(" + str(a) + "x)+(" + str(
            b) + "x))/(" + str(c) + "x)"
        options = coursesFunctionsBll.arithmeticAlternatives(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
예제 #5
0
def gaussSeriesProblem():
    try:
        a = random.randint(10, 100)
        b = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        sol = ((b + (c * a)) + (b + c)) * a / 2
        question = "Which is the sum of the first " + str(
            a) + " terms (from n=1 to n=" + str(
                a) + ") in the function (" + str(b) + "+(" + str(c) + "x)): "
        solution = str(sol)
        options = coursesFunctionsBll.arithmeticAlternatives(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er