コード例 #1
0
def tangencyPointProblem():
    try:
        d = random.randint(11, 20)
        t = random.randint(21, 30)
        x = ((t**2) - (d**2)) / (2 * d)
        sol = round(x + d, 4)
        solution = r"" + str(sol)
        question = r"You are walking towards a circular swimming pool. At some moment you are standing " + str(
            d
        ) + r"ft from the border, while your distance to the point of tangency is " + str(
            t) + r"ft. How many ft are you from the center of the pool?: "
        alternatives = coursesFunctionsBll.multipleOptions([sol], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(alternatives[ta][0]))
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        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 lhospitalProblem():
    try:
        a1 = random.randint(2,10)
        b1 = random.randint(2,10)
        c1 = random.randint(2,11)
        if a1==b1:
            return lhospitalProblem()
        sol1 = "-inf" if (a1/b1<1 and c1%2==1) else "inf"
        a = random.randint(2,10)
        b = random.randint(2,10)
        c = random.randint(2,10)
        d = random.randint(2,10)
        sol=round((a/b)+(c/(d*3)),4)
        solution=""
        question=""
        a0 = random.randint(0,1)
        if a0==1:
            question="find the limit(x->0) of ["+str(a*d)+"ln(x+1)*x^3+"+str(b*c)+"xtan(x)-"+str(b*c)+"x^2]/["+str(b*d)+"x^4]"
            solution=str(sol)
        else:
            question="find the limit(x->inf) of ["+str(round(a1/b1,4))+"^x+ln(x)]/[x^"+str(c1)+"]"
            solution=sol1
        alternatives = coursesFunctionsBll.multipleOptions([sol],3)
        tempAlternatives =[]
        for y in range(3):
            tempAlternatives.append(str(alternatives[y][0]))
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': 'inf', 'e': '-inf'}))
        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 densityProblem():
    try:
        a = random.randint(2,10)
        b = random.randint(2,10)
        c = random.randint(2,10)
        d = random.randint(2,10)
        e = random.randint(11,20)
        mass= random.randint(2,25)
        a1= (a*c)-(2*a*c)
        b1= -(2*c*b)
        c1= (a*d)
        if (b1*b1)<=(4*a1*c1):
            return densityProblem()
        t1= ((-b1)+math.sqrt((b1*b1)-(4*a1*c1)))/(2*a1)
        t2= ((-b1)-math.sqrt((b1*b1)-(4*a1*c1)))/(2*a1)
        vol1= (a*t1+b)/(c*t1**2+d)+e
        vol2= (a*t2+b)/(c*t2**2+d)+e
        denMax = round((mass/vol1),4) if (mass/vol1)>(mass/vol2) else round((mass/vol2),4)
        denMin = round((mass/vol1),4) if (mass/vol1)<(mass/vol2) else round((mass/vol2),4)
        question = "A certain object, which mass is equal to "+str(mass)+"kg, has a volume (in cm^3) equal to ("+str(e*c)+"t^2+"+str(a)+"t+"+str(b+(e*d))+")/("+str(c)+"t^2+"+str(d)+") (t is celcius). Find the maximum and minimum density: "
        solution= "minimum="+str(denMin)+"kg/cm^3. maximum="+str(denMax)+"kg/cm^3"
        proportion= denMax/denMin
        alternatives = coursesFunctionsBll.multipleOptions([denMin],5)
        tempAlternatives =[]
        for y in range(5):
            tempAlternatives.append("minimum="+str(alternatives[y][0])+"kg/cm^3. maximum="+str(round(alternatives[y][0]*proportion,4))+"kg/cm^3")
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        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 circleRegularPolygonProblem2():
    try:
        x = random.randint(10, 20)
        s = random.randint(3, 10)
        angle = (s - 2) * 180 / (s * 2)
        h = (x / 2) * math.tan(angle * math.pi / 180)
        area = round(math.pi * h * h, 4)
        solution = r"" + str(area)
        question = r"For a regular polygon of " + str(
            s) + " sides, where each side have a length of " + str(
                x
            ) + r", find the area of the circle inscribed in this polygon: "
        alternatives = coursesFunctionsBll.multipleOptions([area], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(alternatives[ta][0]))
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        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 quadrilateralProblem():
    try:
        c1 = random.randint(1, 45)
        c2 = random.randint(1, 45)
        a1 = random.randint(2, 10)
        a2 = random.randint(2, 10)
        sol = round((180 - (c1 + c2)) / (a1 + a2), 4)

        solution = r"" + str(sol)
        question = r"A quadrilateral incribed in a circle has inner opposite angles A and B, where A degrees are " + str(
            a1) + r"x+" + str(c1) + r" and B degrees are " + str(
                a2) + r"x+" + str(c2) + r". Which is the value of x?:"
        alternatives = coursesFunctionsBll.multipleOptions([sol], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(alternatives[ta][0]))
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #6
0
def varianceProblem():
    try:
        cards = []
        for i in range(5):
            cards.append(random.randint(1, 20))
        sums = []
        for x in range(5):
            y = x + 1
            while y < 5:
                sums.append(cards[x] + cards[y])
                #sum+=cards[x]+cards[y]
                y += 1
        sol1 = round((sum(s for s in sums)) / 10, 4)
        sol2 = round((sum((s - sol1)**2 for s in sums)) / 10, 4)
        sol3 = round(sol2**(1 / 2), 4)

        solution = r"Expected value=" + str(sol1) + r", variance=" + str(
            sol2) + r", standard deviation=" + str(sol3) + r""
        question = r"In a card game a player has a hand of 5 cards with cards of next values: " + str(
            cards[0]
        ) + r"," + str(cards[1]) + r"," + str(cards[2]) + r"," + str(
            cards[3]
        ) + r"," + str(
            cards[4]
        ) + r". For taking two of this 5 cards find the expected value, variation and standard deviation: "
        alternatives = coursesFunctionsBll.multipleOptions([sol1, sol2, sol3],
                                                           5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"Expected value=" +
                                    str(alternatives[ta][0]) + r", variance=" +
                                    str(alternatives[ta][1]) +
                                    r", standard deviation=" +
                                    str(alternatives[ta][2]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #7
0
def confidenceComparisonSamplesProblem():
    try:
        n1 = random.randint(41, 50)
        n2 = random.randint(31, 40)
        u1 = random.randint(31, 40)
        u2 = random.randint(41, 50)
        s1 = random.randint(2, 5)
        s2 = random.randint(6, 9)
        pOptions = [0.2, 0.1, 0.05, 0.02, 0.01, 0.005]
        p = pOptions[random.randint(0, 5)]
        z = coursesFunctionsBll.normalDistributionInverse(1 - (p / 2))
        sol = round(z * ((((s1**2) / n1) + ((s2**2) / n2))**0.5), 4)
        solution = r"" + str(abs(u1 - u2)) + r" \pm " + str(sol) + r""
        question = r'In a software company the average age of programmers have standard deviation of ' + str(
            s1
        ) + r' years, and for human resources they have a standard deviation of ' + str(
            s2
        ) + r' years. \\ In a sample of ' + str(
            n1
        ) + r' programmers the average age was ' + str(
            u1
        ) + r' years, and in a sample of ' + str(
            n2
        ) + r' human resources employees the average age was ' + str(
            u2
        ) + r' years. \\ Find the confidence interval for the difference of height with a level of ' + str(
            round(100 * (1 - p), 2)) + r'\%. Choose the closest option: '
        alternatives = coursesFunctionsBll.multipleOptions([sol], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(abs(u1 - u2)) + r" \pm " +
                                    str(alternatives[ta][0]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #8
0
def circleKiteProblem():
    try:
        z = random.randint(30, 150)
        a = b = 0
        while True:
            a = random.randint(5, 20)
            b = random.randint(5, 20)
            if a < b:
                break
        area = a * b * math.sin(z * math.pi / 180)
        c = ((a**2) + (b**2) - (2 * a * b * math.cos(z * math.pi / 180)))**(1 /
                                                                            2)
        z1 = z / 2
        #short = round(2*area/long,4)
        #height = short/2
        z2 = math.asin((a / c) * math.sin(z * math.pi / 180)) * 180 / math.pi
        z3 = 180 - z1 - z2
        b2 = b * math.sin(z1 * math.pi / 180) / math.sin(z3 * math.pi / 180)
        b3 = round(math.sin(z2 * math.pi / 180) * b2, 4)

        solution = r"" + str(b3)
        question = r"For a kite with side A with length " + str(
            a
        ) + r" and side B with length " + str(
            b
        ) + r", and angle between them equals to " + str(
            z
        ) + r" degrees, find the radio of the circle inscribed in the kite: "
        alternatives = coursesFunctionsBll.multipleOptions([b3], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(alternatives[ta][0]))
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #9
0
def hyperGeometricVarianceProblem():
    try:
        nk = random.randint(32, 64)
        nx = random.randint(8, 16)
        k = random.randint(8, 16)
        p = k / nk
        q = 1 - p
        sol1 = round(nx * p, 4)
        sol2 = round(nx * p * q * (nk - nx) / (nk - 1), 4)
        sol3 = round(sol2**(1 / 2), 4)
        solution = r"Expected value=" + str(sol1) + r", variance=" + str(
            sol2) + r", standard deviation=" + str(sol3) + r""
        question = r"A glasses factory for this month make " + str(
            nk
        ) + r" glasses, the quality engineer finds that " + str(
            k
        ) + r" glasses are broken. for a group of " + str(
            nx
        ) + r" glasses randomly chosen, find a) \mu b) \sigma^{2} c) \sigma: "
        alternatives = coursesFunctionsBll.multipleOptions([sol1, sol2, sol3],
                                                           5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"Expected value=" +
                                    str(alternatives[ta][0]) + r", variance=" +
                                    str(alternatives[ta][1]) +
                                    r", standard deviation=" +
                                    str(alternatives[ta][2]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #10
0
def kiteSinAreaProblem():
    try:
        z = random.randint(30, 150)
        a = b = 0
        while True:
            a = random.randint(5, 20)
            b = random.randint(5, 20)
            if a != b:
                break
        area = round(a * b * math.sin(z * math.pi / 180), 4)
        long = ((a**2) + (b**2) -
                (2 * a * b * math.cos(z * math.pi / 180)))**(1 / 2)
        short = round(2 * area / long, 4)
        solution = r"area: " + str(area) + r", diagonal: " + str(short) + r""
        question = r"For a kite with side A with length " + str(
            a
        ) + r" and side B with length " + str(
            b
        ) + r", and angle between them equals to " + str(
            z
        ) + r" degrees, find the area of the kite and the length of diagonal which connects the two congruent angles of the kite: "
        alternatives = coursesFunctionsBll.multipleOptions([area, short], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"area: " + str(alternatives[ta][0]) +
                                    r", diagonal: " +
                                    str(alternatives[ta][1]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #11
0
def coneProblem():
    try:
        z = random.randint(2, 10)
        h = random.randint(75, 100)
        d = random.randint(50, 75)
        h0 = random.randint(25, 50)
        sol = round((z*4*(h**2))/(math.pi*(d**2)*(h0**2)),4)
        solution = r""+str(sol)+r"\frac{cm}{s}"
        question=r"A cone turned upside down (so it looks like a v) is being filled with water from the faucet at speed of "+str(z)+r"cm^3/s. If the cone height is "+str(h)+r"cm and base diameter is "+str(d)+r"cm, find the rate change of height of filled cone when this height is "+str(h0)+r"cm: "
        alternatives = coursesFunctionsBll.multipleOptions([sol],5)
        tempAlternatives =[]
        for m in range(5):
            tempAlternatives.append(r""+str(alternatives[m][0])+r"\frac{cm}{s}")
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #12
0
def confidenceBigSamplesProblem():
    try:
        x = random.randint(50, 100)
        m = random.randint(150, 175)
        s = random.randint(5, 10)
        pOptions = [0.2, 0.1, 0.05, 0.02, 0.01, 0.005]
        p = pOptions[random.randint(0, 5)]
        z = coursesFunctionsBll.normalDistributionInverse(1 - (p / 2))
        sol = round(z * s / (x**0.5), 4)
        solution = r"" + str(m) + r" \pm " + str(sol) + r""
        question = r'A sample of ' + str(
            x
        ) + r' school girls give an average height of ' + str(
            m
        ) + r' cms and standard deviation of ' + str(
            s
        ) + r' cms. Find the confidence limit with a ' + str(
            round(100 * (1 - p), 1)
        ) + r'\% for the real height of all the school girls (choose the closest option): '
        alternatives = coursesFunctionsBll.multipleOptions([sol], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(m) + r" \pm " +
                                    str(alternatives[ta][0]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #13
0
def tStudentProblem():
    try:
        x = random.randint(5, 25)
        m = random.randint(100, 200)
        s = random.randint(5, 10)
        pOptions = [0.2, 0.1, 0.05, 0.02, 0.01, 0.005]
        p = pOptions[random.randint(0, 5)]
        t = abs(coursesFunctionsBll.tStudentAprox(p / 2, x - 1))
        sol = round(t * s / (x**0.5), 4)
        solution = r"" + str(m) + r" \pm " + str(sol) + r""
        question = r'A sample of ' + str(
            x
        ) + r' canned tunas give an average weight of ' + str(
            m
        ) + r' grams and standard deviation of ' + str(
            s
        ) + r' grams. Find the confidence limit with a ' + str(
            round(100 * (1 - p), 1)
        ) + r'\% for the real weight of all the canned tunas (choose the closest option): '
        alternatives = coursesFunctionsBll.multipleOptions([sol], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(m) + r" \pm " +
                                    str(alternatives[ta][0]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #14
0
def balloonProblem():
    try:
        volumeChange = random.randint(1,50)
        diameter = random.randint(50,100)
        unit= random.randint(0,2)
        ratio= diameter/2
        units=[["milimeters","mm",10],["micrometers","um",10000],["nanometers","nm",10000000]]
        sol=round((units[unit][2]*volumeChange)/(4*math.pi*(ratio**2)),4)
        question = "A perfectly spherical balloon is inflated and its volume increase by a constant of "+str(volumeChange)+"cm^3/s. How fast changes its ratio when the diameter is "+str(diameter)+"cm? write the answer in "+str(units[unit][0])+"/second ("+str(units[unit][1])+"/s):"
        solution= str(sol)+str(units[unit][1])+"/s"
        alternatives = coursesFunctionsBll.multipleOptions([sol],5)
        tempAlternatives =[]
        for y in range(5):
            tempAlternatives.append(str(alternatives[y][0])+str(units[unit][1])+"/s")
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #15
0
def carDistanceProblem():
    try:
        x = random.randint(250, 500)
        y = random.randint(250, 500)
        dx = random.randint(25, 50)
        dy = random.randint(25, 50)
        h=((x**2)+(y**2))**(1/2)
        sol = round(((x*dx)+(y*dy))/h,4)
        solution = str(sol)+r"\frac{km}{h}"
        question=r"two police cars left the police station (not necessarily at same time), car A moves to the west at speed of "+str(dx)+r"km/h and car B moves the the north at speed of "+str(dy)+r"km/h. At some point car A is at a distance of "+str(x)+r"km from the police station, while car B is at a distance of "+str(y)+r"km from the police station. How fast is increasing the distance between the two cars?: "
        alternatives = coursesFunctionsBll.multipleOptions([sol],5)
        tempAlternatives =[]
        for m in range(5):
            tempAlternatives.append(str(alternatives[m][0])+r"\frac{km}{h}")
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #16
0
def apothemProblem():
    try:
        s0 = random.randint(5, 10)  #number of sides
        l0 = random.randint(10, 100)  #apothem

        a0 = (s0 - 2) * (math.pi)  #total inner angle
        a1 = a0 / s0  #angle per corner
        b0 = (l0 * 2) / math.tan(a1 / 2)  #base per side
        area = round((l0 * b0 / 2) * s0, 4)
        perimeter = round(b0 * s0, 4)

        solution = r"area= " + str(area) + r"cm^{2}, perimeter=" + str(
            perimeter) + r"cm"
        question = r"A regular polygon of " + str(
            s0) + r" sides have an apothem of " + str(
                l0) + r" cm. Find its area and perimeter: "
        alternatives = coursesFunctionsBll.multipleOptions([area, perimeter],
                                                           5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"area= " + str(alternatives[ta][0]) +
                                    r"cm^{2}, perimeter=" +
                                    str(alternatives[ta][1]) + r"cm")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #17
0
def sinTheoremProblem():
    try:
        z = random.randint(10, 20)
        a = b = 90
        while True:
            a = random.randint(1, 178)
            b = random.randint(1, 178)
            if a + b < (180):
                break
        c = 180 - a - b
        constant = z / math.sin(c * math.pi / 180)
        y = constant * math.sin(b * math.pi / 180)
        x = constant * math.sin(a * math.pi / 180)
        sol = round(x + y + z, 4)
        solution = r"" + str(sol) + r"cm"
        question = r"a triangle has angles A, B and C, where angle A is " + str(
            a) + r"°, angle B is " + str(
                b) + r"° and the length of side AB is " + str(
                    z) + r"cm. Find the perimeter of the triangle: "
        alternatives = coursesFunctionsBll.multipleOptions([sol], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(alternatives[ta][0]) + r"cm")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #18
0
def coinProblem():
    try:
        f = random.randint(6, 9)
        e = random.randint(2, 5)
        ne = random.randint(2, 5)
        sol1 = round(
            math.factorial(f) / (math.factorial(e) * math.factorial(f - e) *
                                 (2**f)), 4)
        sol2 = 0
        for i in range(ne):
            sol2 += math.factorial(f) / (math.factorial(i) *
                                         math.factorial(f - i) * (2**f))
        sol2 = round(sol2, 4)
        solution = r"a) " + str(sol1) + r" b)" + str(sol2)
        question = r"from flipping a fair coin  " + str(
            f) + r" times, a) what is the probability of get exactly " + str(
                e) + r" heads b) less than " + str(ne) + r" heads: "
        alternatives = coursesFunctionsBll.multipleOptions([sol1, sol2], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"a) " + str(alternatives[ta][0]) +
                                    r" b)" + str(alternatives[ta][1]))
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #19
0
def pascalVarianceProblem():
    try:
        r = random.randint(6, 15)
        p = random.randint(1, 9) / 10
        q = 1 - p
        sol1 = round(r / p, 4)
        sol2 = round(r * q / (p**2), 4)
        sol3 = round(sol2**(1 / 2), 4)
        solution = r"Expected value=" + str(sol1) + r", variance=" + str(
            sol2) + r", standard deviation=" + str(sol3) + r""
        question = r"Probability for a soccer player to score in a match is " + str(
            round(p * 100)) + r"\%. To arrive to " + str(
                r) + r" matches scoring, find a) \mu b) \sigma^{2} c) \sigma: "
        alternatives = coursesFunctionsBll.multipleOptions([sol1, sol2, sol3],
                                                           5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"Expected value=" +
                                    str(alternatives[ta][0]) + r", variance=" +
                                    str(alternatives[ta][1]) +
                                    r", standard deviation=" +
                                    str(alternatives[ta][2]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #20
0
def balloonFlyProblem():
    try:
        z = random.randint(1, 10)/100
        angleChange = z*math.pi
        a = random.randint(2, 10)
        angle = math.pi/a
        d = random.randint(100, 1000)

        dh = round(((1/math.cos(angle))**2)*angleChange*d,4)
        h = round(math.tan(angle)*d,4)
        solution = r"h="+str(h)+r"mt, \frac{dh}{dt}=\frac{"+str(dh)+r"mt}{m}"
        question=r"A person is watching a balloon, placed in front at "+str(d)+r"mt of distance. Suddenly the balloon begins to fly vertically. The angle between the person and the balloon changes at a constant speed of \frac{"+str(z)+r"\pi}{m}. When angle is \frac{\pi}{"+str(a)+r"}, find height of the balloon and its height change per minute: "
        alternatives = coursesFunctionsBll.multipleOptions([h, dh],5)
        tempAlternatives =[]
        for m in range(5):
            tempAlternatives.append(r"h="+str(alternatives[m][0])+r"mt, \frac{dh}{dt}=\frac{"+str(alternatives[m][1])+r"mt}{m}")
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #21
0
def geometryVarianceProblem():
    try:
        p = random.randint(11, 50) / 100
        q = 1 - p
        sol1 = round(1 / p, 4)
        sol2 = round(q / (p**2), 4)
        sol3 = round(sol2**(1 / 2), 4)
        solution = r"Expected value=" + str(sol1) + r", variance=" + str(
            sol2) + r", standard deviation=" + str(sol3) + r""
        question = r"The probability to call a station radio and get a response is " + str(
            round(p * 100)) + r"\%. Find a) \mu b) \sigma^{2} c) \sigma: "
        alternatives = coursesFunctionsBll.multipleOptions([sol1, sol2, sol3],
                                                           5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"Expected value=" +
                                    str(alternatives[ta][0]) + r", variance=" +
                                    str(alternatives[ta][1]) +
                                    r", standard deviation=" +
                                    str(alternatives[ta][2]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #22
0
def optimizationProblem():
    try:
        a = random.randint(10,100)
        b = random.randint(1,10)
        a1=-2*b
        b1=-8*(b**2)
        c1=2*a*b
        x1=(-b1+math.sqrt((b1**2)-(4*a1*c1)))/(2*a1)
        x2=(-b1-math.sqrt((b1**2)-(4*a1*c1)))/(2*a1)
        xMax=  x1 if x1>x2 else x2
        yMax = (a-(2*b*xMax))/(xMax+(2*b))
        solution= round(xMax*yMax*b,4)
        question="A box without top use a total of "+str(a)+"cm^2 of material. Which is the volume if box height is "+str(b)+"cm and dimensions of the box allows the biggest volume possible: "
        alternatives = coursesFunctionsBll.multipleOptions([solution],5)
        tempAlternatives =[]
        for y1 in range(5):
            tempAlternatives.append(str(alternatives[y1][0]))
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #23
0
def errorProportionProblem():
    try:
        m = random.randint(100, 150)
        p = random.randint(200, 1000)
        a = random.randint(10, 90) / 100
        sol1 = round(((a * (1 - a)) / (m))**(1 / 2), 4)
        sol2 = round((((a * (1 - a)) / (m)) * ((p - m) / (p - 1)))**(1 / 2), 4)
        solution = r"a) " + str(sol1) + r", b) " + str(sol2) + r""
        question = r'In a car factory the ' + str(
            round(a * 100)
        ) + r'\% of productions has mechanical problems. If you make a sample of ' + str(
            m
        ) + r' cars a) find the standard error of proportion supposing factory made infinite cars (or it is a sample with replacement) b) standard error of proportion if total cars made are ' + str(
            p) + r': '
        alternatives = coursesFunctionsBll.multipleOptions([sol1, sol2], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"a) " + str(alternatives[ta][0]) +
                                    r", b) " + str(alternatives[ta][1]) + r"")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #24
0
def newtonCoolingProblem():
    try:
        tempIni = random.randint(76,100)
        tempFin = random.randint(51,75)
        tempFin2 = random.randint(26,50)
        tempEnvi = random.randint(1,25)
        t= random.randint(2,30)
        d = random.randint(2,20)
        t = random.randint(2,20)
        k = math.log((tempFin-tempEnvi)/(tempIni-tempEnvi))/t
        sol=round(math.log((tempFin2-tempEnvi)/(tempIni-tempEnvi))/k,4)
        sol2=round(k*(tempIni-tempEnvi)*(math.e**(k*sol)),4)
        question = "A drink with an initial temperature of "+str(tempIni)+"°F is put on a fridge with a environment temperature equals to "+str(tempEnvi)+"°F. After "+str(t)+" minutes the drink's temperature is "+str(tempFin)+"°F. How many minutes will be need until drink has cooled to "+str(tempFin2)+"°F and which will be the rate of change (F/m) in that moment? use the newton law of cooling: "
        solution= "time="+str(sol)+"m and rate change="+str(sol2)+"°F/m"
        alternatives = coursesFunctionsBll.multipleOptions([sol,sol2],5)
        tempAlternatives =[]
        for y in range(5):
            tempAlternatives.append("time="+str(alternatives[y][0])+"m and rate change="+str(alternatives[y][1])+"°F/m")
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #25
0
def positionProblem():
    try:
        a = random.randint(2,20)
        b = random.randint(2,20)
        c = random.randint(2,20)
        d = random.randint(2,20)
        t = random.randint(2,20)
        a1= a*3
        b1=b*2
        a2=a1*2
        velocity= (a1*t*t)+(b1*t)+c
        acceleration= (a2*t)+b1
        question = "A particle position (through time) is given by the function x="+str(a)+"t^3 + "+str(b)+"t^2 + "+str(c)+"t + "+str(d)+". Finds velocity and acceleration when t="+str(t)+"s:"
        solution= "velocity="+str(velocity)+"m/s and acceleration="+str(acceleration)+"m/s^2"
        alternatives = coursesFunctionsBll.multipleOptions([velocity, acceleration],5)
        tempAlternatives =[]
        for y in range(5):
            tempAlternatives.append("velocity="+str(alternatives[y][0])+"m/s and acceleration="+str(alternatives[y][1])+"m/s^2")
        options =json.loads(json.dumps({'a':tempAlternatives[0], 'b':tempAlternatives[1], 'c': tempAlternatives[2], 'd': tempAlternatives[3], 'e': tempAlternatives[4]}))
        jsonResponse = json.dumps({"question":coursesFunctionsBll.replaceSpace(question), "solution":coursesFunctionsBll.replaceSpace(solution), "options":coursesFunctionsBll.replaceOptions(options)})
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #26
0
def pyramidRegularPolygonProblem():
    try:
        x = random.randint(10, 20)
        s = random.randint(3, 10)
        h = random.randint(10, 20)
        angle = (s - 2) * 180 / (s * 2)
        op = (x / 2) * math.tan(angle * math.pi / 180)
        base = op * x * s / 2
        volume = round((1 / 3) * base * h, 4)
        solution = r"" + str(volume)
        question = r"For a  pyramid where base is a regular polygon of " + str(
            s) + " sides where each side have a length of " + str(
                x) + r",and the pyramid height is " + str(
                    h) + r", find the volume of the pyramid: "
        alternatives = coursesFunctionsBll.multipleOptions([volume], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"" + str(alternatives[ta][0]))
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er
コード例 #27
0
def orthoCenterProblem():
    try:

        point = []
        while True:
            point = [
                [
                    random.randint(1, 10) * (random.randint(0, 1) * 2 - 1),
                    random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
                ],
                [
                    random.randint(1, 10) * (random.randint(0, 1) * 2 - 1),
                    random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
                ],
                [
                    random.randint(1, 10) * (random.randint(0, 1) * 2 - 1),
                    random.randint(1, 10) * (random.randint(0, 1) * 2 - 1)
                ]
            ]
            if (point[0][0] != point[1][0] and point[0][1] != point[1][1]
                ) and (point[0][0] != point[2][0] and point[0][1] !=
                       point[2][1]) and (point[1][0] != point[2][0]
                                         and point[1][1] != point[2][1]):
                if ((point[0][1] - point[1][1]) /
                    (point[0][0] - point[1][0])) != (
                        (point[0][1] - point[2][1]) /
                        (point[0][0] - point[2][0])):
                    break
        m1 = -1 / ((point[0][1] - point[1][1]) / (point[0][0] - point[1][0]))
        c1 = point[2][1] - (m1 * point[2][0])
        m2 = -1 / ((point[0][1] - point[2][1]) / (point[0][0] - point[2][0]))
        c2 = point[1][1] - (m2 * point[1][0])
        x = round((c2 - c1) / (m1 - m2), 4)
        y = round((m2 * x) + c2, 4)

        solution = r"(" + str(x) + r"," + str(y) + r")"
        question = r"Find the orthocenter of triangle with vertices at (" + str(
            point[0][0]) + r"," + str(point[0][1]) + r") (" + str(
                point[1][0]) + r"," + str(point[1][1]) + r") (" + str(
                    point[2][0]) + r"," + str(point[2][1]) + r"): "
        alternatives = coursesFunctionsBll.multipleOptions([x, y], 5)
        tempAlternatives = []
        for ta in range(5):
            tempAlternatives.append(r"(" + str(alternatives[ta][0]) + r"," +
                                    str(alternatives[ta][1]) + r")")
        options = json.loads(
            json.dumps({
                'a': tempAlternatives[0],
                'b': tempAlternatives[1],
                'c': tempAlternatives[2],
                'd': tempAlternatives[3],
                'e': tempAlternatives[4]
            }))
        jsonResponse = json.dumps({
            "question":
            coursesFunctionsBll.replaceSpace(question),
            "solution":
            coursesFunctionsBll.replaceSpace(solution),
            "options":
            coursesFunctionsBll.replaceOptions(options)
        })
        return [jsonResponse]
    except Exception as er:
        return er