Ejemplo n.º 1
0
def ellipseAreaProblem():
    try:
        x01 = random.randint(2, 10) * (random.randint(0, 1) * 2 - 1)
        x02 = random.randint(2, 10) * (random.randint(0, 1) * 2 - 1)
        y0 = random.randint(2, 10) * (random.randint(0, 1) * 2 - 1)
        minor = random.randint(2, 10)
        if x01 == x02:
            return ellipseProblem()
        x0 = (x01 + x02) / 2  #HERE IS X0
        major = ((x01 - x0)**2 + (minor)**2)**(1 / 2)
        area = round(3.1416 * minor * major, 4)
        solution = str(area)
        options = coursesFunctionsBll.generateOptions(area)
        question = "which is the area of ellipse which focus on (" + str(
            x01) + "," + str(y0) + ") (" + str(x02) + "," + str(
                y0) + ") and minor semiaxis equal to " + str(minor) + ""
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 2
0
def areaProblem():
    try:
        a = random.randint(1, 100)
        b = random.randint(1, 100) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(10, 100) * (-1)
        question = 'if a rectangle area is ' + str(
            -1 * c) + ', its height is h and its width is equal to (' + str(
                a) + 'h)+(' + str(
                    b) + '), which is the perimeter of this rectangle?:'
        solution1 = (-b + ((b * b) - (4 * a * c))**(0.5)) / (2 * a)
        solution2 = (-b - ((b * b) - (4 * a * c))**(0.5)) / (2 * a)

        solution = round((solution1 + (solution1 * a) + b) *
                         2, 4) if solution1 > 0 else round(
                             (solution2 + (solution2 * a) + b) * 2, 4)
        options = coursesFunctionsBll.generateOptions(solution)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 3
0
def circleTanProblem():
    try:
        x = random.randint(2, 10) * (random.randint(0, 1) * 2 - 1)
        y = random.randint(2, 10) * (random.randint(0, 1) * 2 - 1)
        m = random.randint(2, 10) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(2, 10) * (random.randint(0, 1) * 2 - 1)
        slope = -1 / m
        intersection = y - (x * slope)
        x1 = (intersection - c) / (m - slope)
        y1 = (x1 * m) + c
        distance = ((x1 - x)**2 + (y1 - y)**2)**(1 / 2)
        diameter = round(distance * 2, 4)
        solution = str(diameter)
        options = coursesFunctionsBll.generateOptions(diameter)
        question = "which is the diameter of a circle where center is in (" + str(
            x) + "," + str(y) + ") and is tangent to the line y=(" + str(
                m) + "x)+(" + str(c) + ")"
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 4
0
def trigonometryLimitProblem2():
    try:
        a = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        b = random.randint(1, 10)
        c = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        d = random.randint(1, 10)
        e = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        if (a * d) + (
                c * b
        ) == 0:  # avoid solution equals 0 since this will be a problem generating the options
            return trigonometryLimitProblem2()
        sol = round(((a * d) + (b * c)) / e, 4)
        solution = str(sol)
        question = "[lim x->(0)] for [((" + str(a) + "x)+(" + str(
            b) + "))((" + str(c) + "x)+(" + str(d) + "))-((" + str(
                b * d) + ")*cos(" + str(e) + "x))]/(" + str(e) + "x)"
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 5
0
def firstGradeEquation():
    try:
        divisor1 = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        dividend1 = random.randint(1, 10)
        divisor3 = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        dividend3 = random.randint(1, 10)
        allDividend = (divisor1 / dividend1) - (divisor3 / dividend3)
        if (allDividend == 0):
            return firstGradeEquation()
        divisor2 = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        dividend2 = random.randint(1, 10)
        divisor4 = random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
        dividend4 = random.randint(1, 10)
        allDivisor = (divisor4 / dividend4) - (divisor2 / dividend2)
        sol = allDivisor / allDividend
        question = "(" + str(divisor1) + "x/" + str(dividend1) + ")+(" + str(
            divisor2) + "/" + str(dividend2) + ")=(" + str(
                divisor3) + "x/" + str(dividend3) + ")+(" + str(
                    divisor4) + "/" + str(dividend4) + ")"
        solution = round(sol, 4)
        options = coursesFunctionsBll.generateOptions(solution)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 6
0
def infiniteLimitProblem2():
    try:
        a = random.randint(1, 5)
        b = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        d = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        e = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        f = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        g = random.randint(1, 5)
        sol = round((a**(0.5)) / c, 4)
        solution = str(sol)
        question = "[Lim x->inf] for [((" + str(a) + "x^" + str(
            2 * g) + ")+(" + str(b) + "x))^(1/2)]((" + str(e) + "x)+(" + str(
                f) + "))/((" + str(c * e) + "x^" + str(g + 1) + ")+(" + str(
                    c * f) + "x^" + str(g) + ")+(" + str(e * d) + "x)+(" + str(
                        d * f) + "))"
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 7
0
def productGeometricProblem():
    try:
        a = random.randint(5, 8)
        b = random.randint(2, 4) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(2, 5) * (random.randint(0, 1) * 2 - 1)
        #sol= (((b*c)*(b*(c**a)))**a)**(0.5)
        sol = (b**a) * (c**sum(list(range(1, a + 1))))
        #sol =  int(format(sol,'.53g'))
        items = []
        for x in range(4):
            items.append(b * (c**(x + 1)))
        question = "The first four elements of a series are " + str(
            items[0]) + "," + str(items[1]) + "," + str(items[2]) + "," + str(
                items[3]) + ", which is the product of the first " + str(
                    a) + " items?:"
        solution = str(sol)
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 8
0
def infiniteLimitProblem():
    try:
        a = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        b = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        d = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        e = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        f = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        g = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        h = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        sol = round(((a * g) + (c * e)) / (c * g), 4)
        solution = str(sol)
        question = "[Lim x->inf] for ((" + str(a) + "x)+(" + str(
            b) + "))/((" + str(c) + "x)+(" + str(d) + ")) + ((" + str(
                e) + "x)+(" + str(f) + "))/((" + str(g) + "x)+(" + str(
                    h) + "))"
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 9
0
def nGeometricProblem():
    try:
        a = random.randint(10, 20)
        b = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(2, 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.generateOptions(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 10
0
def geometricSeriesProblem():
    try:
        a = random.randint(5, 10)
        b = random.randint(1, 5) * (random.randint(0, 1) * 2 - 1)
        c = random.randint(1, 5)
        d = random.randint(1, 5)
        if (c == d):
            return geometricSeriesProblem()
        sol = round((b * (c / d)) * (((c / d)**a) - 1) / ((c / d) - 1), 4)
        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) + "/" + str(d) + ")^x)): "
        solution = str(sol)
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 11
0
def inverseTriProblem():
    try:
        a = random.randint(2,10)
        b = random.randint(2,10)
        c = random.randint(2,10)
        d= random.randint(0,5)
        sol=0
        question=""
        if d==0:
            sol=round(math.log((a*a)/(a*a+c*c))/2,4)
            question = "on which point the function "+str(c)+"*asin(e^x) is parallel to the line "+str(a)+"x+"+str(b)+"?:"
        elif d==1:
            sol=round(math.log((a*a)/(a*a+c*c))/2,4)
            question = "on which point the function "+str(c)+"*acos(e^x) is parallel to the line "+str(a)+"x+"+str(b)+"?:"
        elif d==2:
            sol=round(math.log((a*a+c*c)/(a*a))/2,4)
            question = "on which point the function "+str(c)+"*asec(e^x) is parallel to the line "+str(a)+"x+"+str(b)+"?:"
        elif d==3:
            sol=round(math.log((a*a+c*c)/(a*a))/2,4)
            question = "on which point the function "+str(c)+"*acsc(e^x) is parallel to the line "+str(a)+"x+"+str(b)+"?:"
        elif d==4:
            sol=round(math.log((16*a**4+8*(a**2)*(c**2)+c**4)/(16*a**4))/4,4)
            question = "on which point the function "+str(c)+"*atan(e^x+("+str(c)+"/"+str(2*a)+")) is parallel to the line "+str(a)+"x+"+str(b)+"?:"
        elif d==5:
            sol=round(math.log((16*a**4+8*(a**2)*(c**2)+c**4)/(16*a**4))/4,4)
            question = "on which point the function "+str(c)+"*acot(e^x-("+str(c)+"/"+str(2*a)+")) is parallel to the line "+str(a)+"x+"+str(b)+"?:"
        solution= str(sol)
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 12
0
def exponentialProblem():
    try:
        a = random.randint(2,100)
        b = random.randint(2,100)*(random.randint(0,1)*2-1)
        sol= round(math.log(math.log(a))/math.log(math.e/a),4)
        solution=str(sol)
        question = "for which value of x the function (e^x)-("+str(a)+"^x)+("+str(b)+") has slope equals to zero:"
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 13
0
def divisionProblem():
    try:
        a = random.randint(2,10)
        b = random.randint(2,10)
        c = random.randint(2,10)
        sol=round((a*(2*math.log(c)+1)-(math.log(c)*b)-(math.log(c)*math.log(c)*b))/(a*math.log(c)*(math.log(c)+1)),4)
        solution= str(sol)
        question = "finds x where f'(x)=f''(x) if f(x)=("+str(a)+"x+"+str(b)+")/("+str(c)+"^x): "
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
Ejemplo n.º 14
0
def squareLimitProblem2():
    try:
        a = random.randint(1, 10)
        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 * 2 * (a**(0.5)))), 4)
        solution = str(sol)
        question = "[lim x->(0)] for (((" + str(a) + ")+(" + str(
            b) + "x))^(1/2)-(" + str(a) + ")^(1/2))/(" + str(c) + "x)"
        options = coursesFunctionsBll.generateOptions(sol)
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er