示例#1
0
文件: v1_1.py 项目: SiddhiMudras/coep
def addition():
    r1 = random.randint(3, 10)
    #print(num2words(r1))
    r2 = random.choice(("a", "b", "c", "x", "y", "x"))
    r3 = random.randint(3, 20)
    ques = "The sum of a cetrtain number and " + num2words(
        r1) + " is " + num2words(r3) + ",represent in equation"
    sol = latex(r2 + "+" + str(r1) + "=" + str(r3))
    print(ques)
    #OPTION GENERATION
    op = [0, 0, 0, 0]
    sq = [0, 1, 2, 3]
    ra = random.randint(0, 3)
    op[ra] = sol
    sq.remove(ra)
    op[sq[0]] = latex(str(str(r1) + str(r2)) + "=" + str(r3))
    op[sq[1]] = latex(str(str(r1) + str(r2) + "+" + str(r1)) + "=" + str(r3))
    op[sq[2]] = latex(str(str(r2) + "=" + str(r1)) + "-" + str(r3))
    for i in range(1, 5):
        print(i, ". ", op[i - 1])

    def sol():
        sol1 = "Let's say certain no. will be :" + latex(str(r2)) + "\n"
        sol1 = sol1 + "Sum means addition" + "\n"
        sol1 = sol1 + "Constant terms are : " + latex(
            str(r1)) + " and " + latex(str(r3)) + "\n"
        sol1 = sol1 + "solution would be : " + latex(
            str(r2) + "+" + str(r1) + "=" + str(r3)) + "\n"
        return sol1

    print(sol())
    Solution = sol()
    Corr_op = op[ra]
    wrong_op1 = op[sq[0]]
    Question = ques
    wrong_op2, wrong_op3 = op[sq[1]], op[sq[2]]
    database_dict = database_fn("text",
                                Answer_Type='1',
                                Topic_Number='03020101',
                                Variation='v1',
                                Question=Question,
                                ContributorMail="*****@*****.**",
                                Correct_Answer_1=Corr_op,
                                Wrong_Answer_1=wrong_op1,
                                Wrong_Answer_2=wrong_op2,
                                Wrong_Answer_3=wrong_op3,
                                Solution_text=Solution)
    return database_dict
    value = int(input("Choose one option : "))

    if value == ra + 1:
        print("\nright option")
        print(">--------------------------<")
        sol()
    elif value != ra + 1 and value < 5 and value > 0:
        print("\nwrong option")
        print(">--------------------------<")
        sol()
    else:
        print("invalid choice")
示例#2
0
def main():
    eq=["Two sides of an expression","Two numbers","Two objects","Two things","The weight of potatoes kept on both sides of weighing scale","The size of two cups", "The size of two pillows", "The length of two straight lines","Area of two rectangles"]
    #nteq=["Placing books on bookshelf","Filling water in bucket","Spinning of ferris wheel"]
    #car=random.choice([eq,nteq])
    cop=random.choice(eq)
    #print("Ques :If",cop,"are equal, will it form an equation? - True or False ? \n")
    ques=cop+" are equal. Does the representation of this form an equation? State True or False. \n"
    #print("1 True \n2.False")
    #val=int(input("\nChoose a option : "))
    if cop in eq:
        Solution ="This representation will form an equation because in this situation the Left Hand Side(LHS) will be equal to Right Hand Side(RHS)."
        Corr_op =  "True"
        wrong_op1="False"
    #if cop in nteq:
        #Solution = cop+" will Falset form a equation because in this situation the LHS will Falset be equal to RHS"
        #Corr_op = "False"
        #wrong_op1= True"
    Question = ques
    wrong_op2,wrong_op3 = "",""
    database_dict= database_fn("text",
    Answer_Type='1',
    Topic_Number='030101',
    Variation=3,
    Question=Question,
    ContributorMail="*****@*****.**",                           
    Correct_Answer_1=Corr_op,
    Wrong_Answer_1=wrong_op1,
    Wrong_Answer_2=wrong_op2,
    Wrong_Answer_3=wrong_op3,
    Solution_text=Solution
    )
    return database_dict
示例#3
0
文件: v4_1.py 项目: shubhra-jena/coep
def main():
    eq=["Two sides of an expression are unequal","A see-saw is unbalanced","A lever system is unbalanced","Two sides of a weighing scale are unequal","Length of two stright lines are unequal", "Area of two triangles are unequal", "Area of two squares are unequal", "Weight of two pouches are unequal"]
    #nteq=["Placing books on bookshelf","Filling water in bucket","Spinning of ferris wheel"]
    #car=random.choice([eq,nteq])
    cop=random.choice(eq)
    #print("Ques :If "+cop+", will it form an equation? - True or False ? \n")
    ques= cop+". Does the representation of this form an equation? State True or False. \n"
    #print("1.True \n2.False")
    #val=int(input("\nChoose a option : "))
    if cop in eq:
        Solution = "This representation will Falset form an equation because in this situation the Left Hand Side(LHS) will Falset be equal to Right Hand Side(RHS)."
        Corr_op = "False"
        wrong_op1="True"
    #if cop in nteq:
        #Solution = cop+" will Falset form a equation because in this situation the LHS will Falset be equal to RHS"
        #Corr_op = "False"
        #wrong_op1="True"
    Question = ques
    wrong_op2,wrong_op3 = "",""
    database_dict= database_fn("text",
    Answer_Type='1',
    Topic_Number='030101',
    Variation=4,
    Question=Question,
    ContributorMail="*****@*****.**",                           
    Correct_Answer_1=Corr_op,
    Wrong_Answer_1=wrong_op1,
    Wrong_Answer_2=wrong_op2,
    Wrong_Answer_3=wrong_op3,
    Solution_text=Solution
    )
    return database_dict
示例#4
0
def main_function():
    n1 = maleMarathi()
    n2 = femaleMarathi()
    mapping = {n1: 'He', n2: 'She'}
    name = random.choice([n1, n2])

    r1 = random.randint(10, 25)  #r1 is the no. of years
    r2 = random.randint(1, 6)  #r2 is no. of times Kanwar was elder.
    r3 = random.randint(1, 15)  #r3 is no. of years before
    c = (r1 * r3) + r2  #option 1
    e = (r1 + r2) * r3  #option 3
    f = (r1 + r3) * r2  #option 4

    item = ['bajra', 'wheat', 'jawar', 'maize', 'rice', 'lentils']
    cop = random.choice(item)

    def getQuestion():
        # ques="After "+str(r1)+" years, "+str(n1)+"  shall be "+str(r3)+"  times as old as he was "+str(r3)+" years ago. Find "+mapping[name]+" present age. "
        # return ques
        ques = name + " bought some kilograms of " + (
            cop
        ) + ". " + mapping[name] + " requires " + latex(str(r1)) + latex(
            "kg ") + "per month and " + mapping[name] + " got enough " + (
                cop) + " milled for " + latex(
                    str(r2)
                ) + " months. After that " + mapping[name] + " had " + latex(
                    str(r3)) + latex("kg ") + " left. How much " + (
                        cop) + " had " + name + " bought altogether?"
        return ques

    question = getQuestion()
    corr = (r1 * r2) + r3
    CorrectAnswer1 = corr
    Wrong_Answer_1, Wrong_Answer_2, Wrong_Answer_3 = [c, e, f]

    sol = 'Let the amount of ' + cop + ' bought by ' + name + ' be' + latex(
        ' x.') + '<br>' + 'Hence,' + '<br>' + latex('x-(') + latex(
            str(r1)
        ) + '*' + latex(str(r2)) + '=' + latex(str(r3)) + ')' + '<br>' + latex(
            'x  - ') + latex(str(r1 * r2)) + ' = ' + latex(
                str(r3)) + '<br>' + latex('x') + ' = ' + latex(
                    str((r1 * r2) + r3)) + latex(
                        'kg '
                    ) + '<br>' + ' Hence, ' + name + ' had bought ' + latex(
                        str((r1 * r2) +
                            r3)) + latex('kg ') + cop + ' altogether.'

    database_dict = database_fn(Answer_Type='text',
                                Topic_Number='0302',
                                Variation=17,
                                Question=question,
                                Correct_Answer_1=CorrectAnswer1,
                                Wrong_Answer_1=Wrong_Answer_1,
                                Wrong_Answer_2=Wrong_Answer_2,
                                Wrong_Answer_3=Wrong_Answer_3,
                                ContributorMail='*****@*****.**',
                                Solution_text=sol)
    return database_dict
示例#5
0
def main():
    print("Ques. Which of the following is not an equation ?")
    ques = "Which of the following is not an equation ?"
    op = [0, 0, 0, 0]
    sq = [0, 1, 2, 3]
    wr = [line(), notequi(), num()]
    ra = random.randint(0, 3)
    op[ra] = random.choice(wr)
    sq.remove(ra)
    op[sq[0]] = equi()
    op[sq[1]] = equi()
    op[sq[2]] = equi()
    for i in range(1, 5):
        print(i, ". ", op[i - 1])

    def sol():
        sol = "Solution: " + latex(op[ra])
        sol = sol + "Equation can be defined as a mathematical statement \nin which two expressions are set equal to each other"
        return sol


##            print("In option => ",op[ra])
##            print("=> ",varx, " is the variable and ",x1,varx," is the variable term")
##            print("=> ",y2," and ",c3," are the constant terms")

    Solution = sol()
    Corr_op = op[ra]
    wrong_op1 = op[sq[0]]
    Question = ques
    wrong_op2, wrong_op3 = op[sq[1]], op[sq[2]]
    database_dict = database_fn("text",
                                Answer_Type='1',
                                Topic_Number='030102',
                                Variation='v1',
                                Question=Question,
                                ContributorMail="*****@*****.**",
                                Correct_Answer_1=Corr_op,
                                Wrong_Answer_1=wrong_op1,
                                Wrong_Answer_2=wrong_op2,
                                Wrong_Answer_3=wrong_op3,
                                Solution_text=Solution)
    return database_dict
    value = int(input("Choose one option : "))
    if value == ra + 1:
        print("\nright option")
        print(">--------------------------<")
        sol()
    elif value != ra + 1 and value < 5 and value > 0:
        print("\nwrong option")
        print(">--------------------------<")
        sol()
    else:
        print("invalid choice")
示例#6
0
def main():
    eq=["Balanced see-saw","Simple pulley system","Analog weighing machine","Car-towing","A lever system"]
    nteq=["Placing books on bookshelf","Filling water in bucket","Spinning of ferris wheel"]
    car=random.choice([eq,nteq])
    cop=random.choice(car)
    print("Ques : ",cop," is an equation - True or False ? \n")
    ques=cop+" is an equation - True or False ? \n"
    print("1.True \n2.False")
    val=int(input("\nChoose a option : "))
    if cop in eq:
        Solution = cop+" will form a equation because in this situation the LHS will be equal to RHS"
        Corr_op = "True"
        wrong_op1="False"
    if cop in nteq:
        Solution = cop+" will not form a equation because in this situation the LHS will not be equal to RHS"
        Corr_op = "False"
        wrong_op1="True"
    Question = ques
    wrong_op2,wrong_op3 = "",""
    database_dict= database_fn("text",
    Answer_Type='1',
    Topic_Number='030101',
    Variation='v1',
    Question=Question,
    ContributorMail="*****@*****.**",                           
    Correct_Answer_1=Corr_op,
    Wrong_Answer_1=wrong_op1,
    Wrong_Answer_2=wrong_op2,
    Wrong_Answer_3=wrong_op3,
    Solution_text=Solution
    )
    return database_dict
    if val==1 and cop in eq:
        print("Right Option")
        print("Solution : ")
        print(cop," will form a equation because in this situation the LHS will be equal to RHS")
        #return
    if val==2 and cop in nteq:
        print("Right Option")
        print("Solution : ")
        print(cop," will not form a equation because in this situation the LHS will not be equal to RHS")
        #return
    elif val not in [1,2]:
        print("Invalid Choice")
    else:
        print("Wrong Option")
        if cop in eq:
            print("Solution : ")
            print(cop," will form a equation because in this situation the LHS will be equal to RHS")
            #return
        elif cop in nteq:
            print("Solution : ")
            print(cop," will not form a equation because in this situation the LHS will not be equal to RHS")
示例#7
0
文件: v2_1.py 项目: shubhra-jena/coep
def main_function():
    n1 = maleMarathi()
    n2 = femaleMarathi()
    item = [
        'books', 'flowers', 'bottles', 'plates', 'spoons', 'pencils',
        'erasers', 'staplers', 'sharperners', 'rulers', 'pens', 'brushes',
        'crayons'
    ]
    cop = random.choice(item)
    arr1 = ['a', 'b', 'c', 'm', 'n', "x", "y", 'z']
    variable = latex(random.choice(arr1))

    def getQuestion():
        ques = n1 + " is having same number of " + cop + " as " + n2 + " has. Each one of them is having how many " + cop + "?"
        return ques

    def getWrongAnswers():
        options = [
            latex(random.randint(0, 4)),
            latex(random.randint(5, 7)),
            latex(random.randint(8, 10))
        ]
        random.shuffle(options)
        return options

    solu = "Since we do not know the exact number of " + str(
        cop) + " with " + str(n1) + " and " + str(
            n2) + " let us use letter " + str(
                variable) + " to represent the unknown number of " + str(
                    cop) + " with " + str(n1)
    solu = solu + " and since " + str(n2) + " holds equal number of " + str(
        cop) + " we can represent the number of " + str(
            cop) + " with her again as " + str(variable) + "."
    question = getQuestion()
    CorrectAnswer1 = variable
    Wrong_Answer_1, Wrong_Answer_2, Wrong_Answer_3 = getWrongAnswers()

    database_dict = database_fn(Answer_Type='text',
                                Topic_Number='030101',
                                Variation=2,
                                Question=question,
                                Correct_Answer_1=CorrectAnswer1,
                                Wrong_Answer_1=Wrong_Answer_1,
                                Wrong_Answer_2=Wrong_Answer_2,
                                Wrong_Answer_3=Wrong_Answer_3,
                                ContributorMail='*****@*****.**',
                                Solution_text=solu)
    return database_dict
示例#8
0
def main():
    e0, e1, e2, corr_op = generate_expression()
    #print([e0,e1,e2])
    exp, Question = print_questions([e0, e1, e2])
    print_options()
    #take_input(not(corr_op))
    wrong_op = not (corr_op)
    Solution = print_solution(exp)

    database_dict = database_fn(Answer_Type='4',
                                Topic_Number='030102',
                                Variation='v8_1',
                                Question=Question,
                                Correct_Answer_1=corr_op,
                                Wrong_Answer_1=wrong_op,
                                Solution_text=Solution,
                                ContributorMail="*****@*****.**")
    return database_dict
示例#9
0
def main():
    global lhsConst, rhsConst
    global question, correctAnswer1, wrongAnswer1, wrongAnswer2, wrongAnswer3, solutionText
    lhsConst = rd.randint(1, 50)
    rhsConst = rd.randint(1, 50)
    generateQuestion()
    database_dict = database_fn(
        Answer_Type='Text',
        Topic_Number='030202',
        Variation=1,
        Question=question,
        Correct_Answer_1=correctAnswer1,
        Wrong_Answer_1=wrongAnswer1,
        Wrong_Answer_2=wrongAnswer2,
        Wrong_Answer_3=wrongAnswer3,
        ContributorMail='*****@*****.**',
        Solution_text=solutionText)
    return database_dict
示例#10
0
def main():
    e0, e1 = generate_expression(0)
    exp = [e0, e1]
    #print([e0,e1,e2])
    Question = print_questions()
    corr_op, wrong_op1, wrong_op2, wrong_op3 = print_options(exp)
    #take_input(not(corr_op))
    wrong_op = not (corr_op)
    Solution = print_solution(exp)

    database_dict = database_fn(Answer_Type='1',
                                Topic_Number='030201',
                                Variation='v3_1',
                                Question=Question,
                                Correct_Answer_1=corr_op,
                                Wrong_Answer_1=wrong_op1,
                                Wrong_Answer_2=wrong_op2,
                                Wrong_Answer_3=wrong_op3,
                                Solution_text=Solution,
                                ContributorMail="*****@*****.**")
    return database_dict
示例#11
0
def main_function():
    n1 = maleMarathi()
    n2 = femaleMarathi()
    mapping = {n1: 'his', n2: 'her'}
    name = random.choice([n2, n1])

    p1 = random.randint(1, 20)  #p1 is the no. of years
    p2 = random.randint(2, 5)  #p2 is no. of times Kanwar was elder.
    p3 = random.randint(1, 20)  #p3 is no. of years before
    c = round(((p2 * p3) + p1) / (p2 + 1))  #option 1
    e = round(((p2 * p3) - p1) / (p2 + 1))  #option 3
    f = round(((p2 * p3) - p1) / (p2 - 1))  #option 4

    #ranges for the variables
    p1 = random.randint(1, 20)  #p1 is the no. of years
    p2 = random.randint(2, 5)  #p2 is no. of times Kanwar was elder.
    p3 = random.randint(1, 20)  #p3 is no. of years before

    while (p2 * p3 + p1) % (p2 - 1):
        p1 = random.randint(1, 20)  #p1 is the no. of years
        p2 = random.randint(2, 10)  #p2 is no. of times Kanwar was elder.
        p3 = random.randint(1, 20)  #p3 is no. of years before

    def getquestion():
        ques = "After " + latex(
            str(p1)) + " years, " + str(n1) + "  shall be " + latex(
                str(p3)) + "  times as old as he was " + latex(
                    str(p3)
                ) + " years ago. Find " + mapping[name] + " present age. "
        return ques

    question = getquestion()
    corr = round(((p2 * p3) + p1) / (p2 - 1))
    correctanswer1 = corr
    wrong_answer_1, wrong_answer_2, wrong_answer_3 = [c, e, f]

    def getsol():
        sol = 'Let ' + str(n1) + '\'s' + ' current age be ' + latex(
            'x') + '.<br>'
        sol = sol + 'Hence, ' + latex('x') + '+' + latex(
            str(p1)) + ' = ' + latex(str(p2)) + '*' + latex(
                str('(x-' + str(p3) + ')\n')) + '<br>'
        sol = sol + latex('x') + '+' + latex(str(p1)) + ' = ' + latex(
            str(p2)) + latex('x') + '-' + latex(str(p2 * p3)) + ".<br>"
        sol = sol + latex(str((p2 - 1))) + latex('x') + ' = ' + latex(
            str((p2 * p3) + p1)) + '\n<br>'
        sol = sol + latex('x') + ' = ' + latex(str(
            ((p2 * p3) + p1) / (p2 - 1))) + '\n<br>'
        sol = sol + 'Hence, ' + str(n1) + ' is ' + latex(
            str(round(((p2 * p3) + p1) / (p2 - 1)))) + ' years old presently.'
        return sol

    # elif choice in [1,2,3,4]:
    #     print('Your answer is incorrect!')
    #     print('The correct answer is option', corr)
    #     print('\n-------- SOLUTION----------\n')
    #     sol()
    # else:
    #     print("Invalid input")

    database_dict = database_fn(Answer_Type='text',
                                Topic_Number='0302',
                                Variation=18,
                                Question=question,
                                Correct_Answer_1=correctanswer1,
                                Wrong_Answer_1=wrong_answer_1,
                                Wrong_Answer_2=wrong_answer_2,
                                Wrong_Answer_3=wrong_answer_3,
                                ContributorMail='*****@*****.**',
                                Solution_text=getsol())
    return database_dict
示例#12
0
def main_function():
    change_globals()
    eq=["If "+n1+" has "+latex(str(r1))+i+" and "+n2+" has "+latex(str(r2))+i+" then "+n2+" has "+latex(str(r3))+" times the "+i+" that "+n1+" has" ,"In a Tug of War if no side wins","A weighing scale having its needle in center","Two persons sitting on either side of a See-Saw, having equal weights","If there are equal weights in both pans of a weighing scale, then the scale is balanced. Such a balanced scale is like an equation.","If "+n1+" has "+latex(str(r4))+i+" and "+n2+" has "+latex(str(r5))+i+" then "+n2+" has "+latex(str(r6))+i+" more than "+n1]
    nteq=["If "+n1+" has "+latex(str(r1))+i+" and "+n2+" has "+latex(str(r2))+i+" then "+n2+" has "+latex("2")+" times the "+i+" that "+n1+" has","A See-Saw having only one person sitting on a side","Two persons A and B are sitting on either side of a See-Saw. Person A is having more weight than Person B","In a Tug of War if a side wins","A weighing machine having "+latex("2")+" Kg  rice on one side and "+latex("1")+" Kg sugar on the other side","If "+n1+" has "+latex(str(r4))+i+" and "+n2+" has "+latex(str(r5))+i+" then "+n2+" has "+latex(str(r7))+i+" more than "+n1]
    #same time same speed same distance
    ques1=random.choice([eq,nteq])
    cop=random.choice(ques1)
    ques_f=cop+", it is an equation. State True or False.\n"
    print(ques_f)
    o1="option 1 : True"
    o2="option 2 : False"

##    r=random.randint(0,5)
##    if r>3:
##        o1="option 1 : False"
##        o2="option 2 : True"

    print(o1)
    print(o2)
    print("")
    val=1#int(input("Enter the option number : "))
    # if val==1 and cop in eq:
        
    #         sol=("Your answer is correct")
    #         sol=sol+("------------ SOLUTION -------------")
    #         sol=sol+("Since, we know that, an equation is defined as a mathematical statement consisting of two algebraic expressions having the same value")
    #         sol=sol+("So, in an equation there is always an '=' sign and the expression on the right hand side of the '=' sign is called the RHS.\nThe expression on the left hand side of the '=' sign is called the LHS.")
    #         sol=sol+("Therefore, according to the question, LHS is equal to RHS")
    #         sol=sol+("Thus,"+ cop +" will form an equation")
            
    # if val==2 and cop in nteq:
        
    #         sol=("Your answer is correct")
    #         sol=sol+("------------ SOLUTION -------------")
    #         sol=sol+("Since, we know that, an equation is defined as a mathematical statement consisting of two algebraic expressions having the same value")
    #         sol=sol+("So, in an equation there is always an '=' sign and the expression on the right hand side of the '=' sign is called the RHS.\nThe expression on the left hand side of the '=' sign is called the LHS.")
    #         sol=sol+("Therefore, according to the question, LHS is not equal to RHS")
    #         sol=sol+("Thus, "+cop+" will not form an equation")
           
    # elif val not in [1,2]:
    #         print("Invalid Choice")
    # else:
    #         print("Your answer is incorrect")
    #         if cop in eq:
    #             print("------------ SOLUTION ------------- ")
    #             print("Since, we know that, an equation is defined as a mathematical statement consisting of two algebraic expressions having the same value")+"\n"
    #             print("So, in an equation there is always an '=' sign and the expression on the right hand side of the '=' sign is called the RHS.\nThe expression on the left hand side of the '=' sign is called the LHS.")+"\n"
    #             print("Therefore, according to the question, LHS is equal to RHS")
    #             print("Thus, "+cop+" will form an equation")
                
    #         elif cop in nteq:
    #             print("------------ SOLUTION --------------- ")
    #             print("Since, we know that, an equation is defined as a mathematical statement consisting of two algebraic expressions having the same value")
    #             print("So, in an equation there is always an '=' sign and the expression on the right hand side of the '=' sign is called the RHS.\nThe expression on the left hand side of the '=' sign is called the LHS.")
    #             print("Therefore, according to the question, LHS is not equal to RHS")
    #             print("Thus, "+cop+" will not form an equation")
               
    if cop in eq:

        
        sol=("An equation is defined as a mathematical statement consisting of two algebraic expressions having the same value")
        sol=sol+('''<br/>So, in an equation there is always an '=' sign,
The expression on the right hand side of the '=' sign is called the RHS.
The expression on the left hand side of the '=' sign is called the LHS
''')
        sol=sol+("<br/>An equation is formed only if LHS is equal to RHS")
        sol=sol+("<br/>But in this question, LHS is equal to RHS")
        sol=sol+("<br/>Thus, "+ cop +" will form an equation")
        Solution = sol
        Corr_op = "True"
        wrong_op1="False"
    if cop in nteq:

        
        sol=("An equation is defined as a mathematical statement consisting of two algebraic expressions having the same value")
        sol=sol+('''<br/>So, in an equation there is always an '=' sign ,
The expression on the right hand side of the '=' sign is called the RHS.
The expression on the left hand side of the '=' sign is called the LHS
''')
        sol=sol+("<br/>An equation is formed only if LHS is equal to RHS")
        sol=sol+("<br/>But in this question, LHS is not equal to RHS")
        sol=sol+("<br/>Thus, "+ cop +" will not form an equation")
        Solution = sol
        Corr_op = "False"
        wrong_op1="True"
    database_dict= database_fn(
    'text',
    Answer_Type='4',
    Topic_Number='030101',
    Variation=6,
    Question=ques_f,
    Correct_Answer_1=Corr_op,
    Wrong_Answer_1=wrong_op1,
    ContributorMail='*****@*****.**',
    Solution_text=Solution
    )
    return database_dict            
示例#13
0
    def hard():
        r1 = random.randint(2, 12)
        if r1 % 2 != 0:
            r1 = r1 + 1
        r3 = random.randint(21, 41)
        if r3 % 2 != 0:
            r3 = r3 + 1
        x = r3 / r1

        ques = "Solve for x, " + to_frac(str(r3), "x") + latex("= " + str(r1))

        op = [0, 0, 0, 0]
        sq = [0, 1, 2, 3]
        o1 = r3 * r1
        o2 = r3 - r1
        o3 = x
        o4 = r1 / r3
        ra = random.randint(0, 3)
        op[ra] = o3
        sq.remove(ra)
        op[sq[0]] = o1
        op[sq[1]] = o2
        op[sq[2]] = o4
        for i in range(1, 5):
            print(i, ". ", op[i - 1])

        def sol():
            sol1 = "solution: \n"
            sol1 = sol1 + to_frac(str(r3), "x") + latex("=" + str(r1)) + "\n"
            sol1 = sol1 + latex("x = ") + to_frac(
                str(r3), str(r1)) + "(Multiplying by x on both sides)" + "\n"
            sol1 = sol1 + latex("x = " + str(x))
            return sol1

        solution = sol()
        Question = ques
        Corr_op = op[ra]
        wrong_op1, wrong_op2, wrong_op3 = op[sq[0]], op[sq[1]], op[sq[2]]
        Solution = solution
        database_dict = database_fn("text",
                                    Answer_Type='1',
                                    Topic_Number='030203',
                                    Variation='v8',
                                    Question=Question,
                                    Correct_Answer_1=Corr_op,
                                    Wrong_Answer_1=wrong_op1,
                                    Wrong_Answer_2=wrong_op2,
                                    Wrong_Answer_3=wrong_op3,
                                    Solution_text=solution)
        return database_dict

        print(" option 1 : ", o1, "\n", "option 2 : ", o2, "\n", "option 3 : ",
              o3, "\n", "option 4 : ", "%.3f" % o4, "\n")

        value = int(input("Choose one option : "))

        if value == 1:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        elif value == 2:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        elif value == 3:
            print("\nright option")
            print(">--------------------------<")
            sol()
        elif value == 4:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        else:
            print("\nInvalid Choice")
示例#14
0
def main_function():
    
    total_set = [10000, 20000, 30000, 40000, 50000,80000,100000]
    
    people_set = [150,200,250,300,400,500,600]

    dist_set = [50, 100,150,200,500,1000]

    v1,v2=0,0
    while(v1<=v2 or total<=v2*people or v1*people < total or (total - v2*people)%(v1 - v2) != 0):
        v1,v2 = random.choices(dist_set, k=2)
        total = random.choice(total_set)
        people = random.choice(people_set)

    item_set = ['gift', 'prize', 'coupon']
    item = random.choice(item_set)
    
    def get_question():
        q = "A total of " + latex("Rs") + " " +latex(str(total)) + " is distributed among " + latex(str(people)) + " persons as " + item +"s" + ". A " + str(item) + " is either of " + latex("Rs") + " " + latex(str(v1)) + " or " + latex("Rs") + " " + latex(str(v2)) + ". Find the number of " + item +"s" + " of each type."
        return q

    def soln():
        sol1 = "Total number of " + item + "s" + " = " + latex(str(people)) + '<br>' + " Let the number of " + item + "s of " + latex("Rs") + ' ' + latex(str(v1)) + ' ' + " be " + latex("x") + "." + "<br>" + "Then the number of " + item + 's of ' + latex("Rs") + ' ' + latex(str(v2)) + ' is ' + latex(str('(' + str(people) + " - x" + ")" ))  + '<br>' 
        sol1 = sol1 + ' Amount spent on ' + latex('x') + ' ' +item +'s' + " of " + latex("Rs") + " " + latex(str(v1)) + " = " + latex("Rs") + " " + latex(str(v1) + "x") + "<br>"
        sol1 = sol1 + " Amount spent on " + latex(str("(" + str(people) + " - x" + ")")) + ' ' + item + 's' + ' of ' + latex("Rs") + ' ' + latex(str(v2)) + " = " + latex("Rs") + ' ' + latex(str(str(v2) + "(" + str(people) + " - x" + ")")) + "<br>"
        sol1 = sol1 + " Total amount spent for " + item + 's = ' + latex("Rs") + ' ' + latex(str(total)) + '<br>'  
        sol1 = sol1 + " According to the question, " + '<br>'
        sol1 = sol1 + latex(str(str(v1) + "x")) + " + " + latex(str(v2)) + latex(str( "(" + str(people) + '- x' + ')')) + ' = ' + latex(str(total)) + "<br>"
        sol1 = sol1 + " => " + latex(str(str(v1) + "x"))  + " + " + latex(str((v2*people))) + " - " + latex(str(str(v2) +"x ")) + " = " + latex(str(total)) + "<br>"
        sol1 = sol1 + " => " + latex(str(str(v1-v2) + 'x')) + ' = ' + latex(str(total)) + ' - ' + latex(str(v2*people)) + "<br>"
        sol1 = sol1 + " => " + latex(str(str(v1-v2) + 'x')) + ' = ' + latex(str(total - v2*people)) +  "<br>" + '=>' + latex('x') + ' = ' + latex(str(str(total - v2*people) + "/" + str(v1-v2))) + "<br>"
        sol1 = sol1 + " => " + ' ' + latex('x') + ' = ' + latex(str(int((total - v2*people)/(v1 - v2)))) + "<br>"
        sol1 = sol1 + " => " + latex(str(str(people) + '- x')) + ' = ' + latex(str(people)) + ' - ' + latex(str(x))  + ' = ' + latex(str(people-x)) + "<br>"
        return sol1  

    x = int((total - v2*people)/(v1 - v2))
    solution = soln()

    a = latex(x) + " , " +latex(str(people-x))
    b = latex(str(x-10)) +  " , " + latex(str(people-x+15))
    c = latex(str(x-10)) +  " , " + latex((people-x+10))
    d = latex(str(x-5)) +  " , " + latex(str(people-x+5))

    def correctans():
        return a

    correct_answer_1 = correctans()
    wrong_answer_1, wrong_answer_2, wrong_answer_3 = [b,c,d]
    
    question = get_question()

    database_dict = database_fn(Question_Type='text', 
                                Answer_Type='text', 
                                Topic_Number= '0302', 
                                Variation=16,
                                Question=question,
                                Correct_Answer_1=correct_answer_1,
                                Wrong_Answer_1=wrong_answer_1,
                                Wrong_Answer_2=wrong_answer_2,
                                Wrong_Answer_3=wrong_answer_3,
                                ContributorMail='*****@*****.**',
                                Solution_text=solution
                                )
    return database_dict
示例#15
0
def main_function():
    n1 = randomMarathi()

    r2 = random.randint(1, 25)

    r1 = random.randint(30, 100)

    # option 1
    x1 = (r1 + r2 + 1)

    # option 2
    x4 = abs(r1 - r2 - 1)

    # option 3
    x3 = (r1 + r2)

    # option 4
    x2 = abs(r1 - r2)

    items = ['sheeps', 'books', 'pens', 'sheets', 'toys', 'candies', 'pencils', 'shirts', 'pants', 'T-shirts',
             'jackets',
             'bananas', 'chocolates', 'watermelons', 'cookies']

    i = random.choice(items)

    # print( n1+' and '+n2+' have a total of '+str(r1)+' ',i,'.')
    # print(
    #     n1 + ' has some ' + i + '.' + 'After buying ' + str(r2) + ' more from the market,' + n1 + ' has ' + str(
    #         r1), i + '.How many', i, n1 + ' had initially?')
    # # print('How many', i, n1 + ' have initially?')
    r = random.randint(1, 5)

    # temp1 = n1 + ' has a total of ' + str(r1) + ' ' + i + '.'
    temp1 = n1 + ' has some ' + i + '.' + 'After buying ' + str(r2) + ' more from the market,' + n1 + ' has ' + str(
        r1) + ' ' + i + '.'

    # temp2 = 'If ' + n2 + ' has ' + str(r2) + ' more ' + i + ' than ' + n1 + ', how many ' + i + ' does each one have?\n'
    temp2 = 'How many ' + i + ' ' + n1 + ' had initially?'
    #
    question = temp1 + temp2
    print(question)

    op = ["", "", "", ""]
    sq = [0, 1, 2, 3]
    # option variables
    o1 = n1 + ''' has ''' + str(int(x1)) + ''' ''' + i
    o2 = n1 + ''' has ''' + str(int(x4)) + ''' ''' + i
    o3 = n1 + ''' has ''' + str(int(x2)) + ''' ''' + i
    o4 = n1 + ''' has ''' + str(int(x3)) + ''' ''' + i

    ra = random.randint(0, 3)
    op[ra] = o3
    sq.remove(ra)
    op[sq[0]] = o1
    op[sq[1]] = o2
    op[sq[2]] = o4
    # PRINTING OPTIONS
    for z in range(1, 5):
        print("Option", z, ":", op[z - 1])
    print("")
    value = 3  # int(input("Enter the option number:"))

    def sol():
        sol = 'Let the number of ' + i + " with " + str(n1) + ' initially be ' + latex(
            'x') + '.' + '<br/> After buying ' + str(r2) + ' ' + i + ' ' + str(n1) + ' has ' + str(
            r1) + ' ' + i + ' left' + '<br/> Total number of ' + i + ' = Initial number of ' + i + ' + Number of ' + i + ' bought ' + '<br/> Therefore ' + latex(
            'x + ' + str(r2) + ' = ' + str(r1)) + '<br/>' + latex(
            '<br/> x + ' + str(r2) + ' ''- ' + str(r2) + ' = ' + str(r1) + ' - ' + str(r2)) + '  (Subtract ' + latex(str(
            r2)) + ' from both sides)' 
        a = r1 - r2
        sol = sol + '<br/>' + latex('<br/> x + 0 = ') + latex(str(a)) + '<br/>'
        sol = sol + latex("<br/> x = ") + latex(str(a))
        sol = sol + '<br/> Therefore, ' + latex('x' + ' = ' + str(a))
        sol = sol + '<br/> Thus, there were ' + latex(str(a)) + ' ' + i + ' with ' + n1 + ' initially'

        return sol

    if value == ra + 1:
        print("\nYour answer is Correct!!!")
        print("~********** SOLUTION **********~")
        sol()
    elif value != ra + 1 and value < 5 and value > 0:
        print("\nYour answer is incorrect!!")
        print("~********** SOLUTION **********~")
        sol()
    else:
        print("Invalid Choice")

    database_dict = database_fn(
        Answer_Type='1',
        Topic_Number='030203',
        Variation='v3_14',
        Question=question,
        Correct_Answer_1=o3,
        Wrong_Answer_1=o1,
        Wrong_Answer_2=o2,
        Wrong_Answer_3=o4,
        ContributorMail='*****@*****.**',
        Solution_text=sol()
    )
    return database_dict
示例#16
0
    def easy():
        r1 = random.randint(2, 21)
        r2 = random.randint(1, 10)
        r3 = r1 * r2
        x = r3 / r1
        ques = "Solve for x, " + latex(str(r1) + "x = " + str(r3))

        op = [0, 0, 0, 0]
        sq = [0, 1, 2, 3]
        o1 = r3 * r1
        o2 = r3 - r1
        o3 = x
        o4 = r3 + r1
        ra = random.randint(0, 3)
        op[ra] = o3
        sq.remove(ra)
        op[sq[0]] = o1
        op[sq[1]] = o2
        op[sq[2]] = o4
        for i in range(1, 5):
            print(i, ". ", op[i - 1])

        def sol():
            sol1 = "solution: \n"
            sol1 = sol1 + latex(str(r1) + "x = " + str(r3))
            sol1 = sol1 + latex("x = ") + to_frac(
                str(r3),
                str(r1)) + "(dividing by " + str(r1) + " on both sides)"
            sol1 = sol1 + latex("x = " + str(x))
            return sol1

        solution = sol()
        Question = ques
        Corr_op = op[ra]
        wrong_op1, wrong_op2, wrong_op3 = op[sq[0]], op[sq[1]], op[sq[2]]
        Solution = solution
        database_dict = database_fn("text",
                                    Answer_Type='1',
                                    Topic_Number='030203',
                                    Variation='v5',
                                    Question=Question,
                                    Correct_Answer_1=Corr_op,
                                    Wrong_Answer_1=wrong_op1,
                                    Wrong_Answer_2=wrong_op2,
                                    Wrong_Answer_3=wrong_op3,
                                    Solution_text=solution)
        return database_dict

        print(" option 1 : ", int(o1), "\n", "option 2 : ", int(o2), "\n",
              "option 3 : ", int(o3), "\n", "option 4 : ", int(o4), "\n")

        value = int(input("Choose one option : "))

        if value == 1:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        elif value == 2:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        elif value == 3:
            print("\nright option")
            print(">--------------------------<")
            sol()
        elif value == 4:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        else:
            print("\nInvalid Choice")
示例#17
0
def main_function():
    name = femaleMarathi()
    given_c = random.randint(5, 20)
    left_c = random.randint(10, 20)
    total_c = given_c + left_c
    food_capacity = random.randint(100, 300)
    amount_grams = food_capacity * total_c
    food_items = [
        'jam', 'chocolate', 'ice cream', 'nutella', 'cake', 'candies', 'pohe'
    ]
    food = food_items[random.randint(0, len(food_items) - 1)]

    ques = f"{name} prepared some {food} at home and filled it in containers. After giving away {latex(given_c)} of the containers to her friends,she still has {latex(left_c)} for herself.\nHow many containers did she fill? If she filled {latex(food_capacity)}g of {food} in each container,what was the total weight of {food} she made? \n"

    options = [None] * 4  #creating an empty list to store options

    options[
        0] = f"{name} made a total of {latex(total_c)} containers and the total weight of the {food} is {latex(amount_grams)} "
    options[
        1] = f"{name} made a total of {latex(total_c)} containers and the total weight of the {food} is {latex(amount_grams+food_capacity)}"
    options[
        2] = f"{name} made a total of {latex(left_c +1+ given_c)} containers and the total weight of the {food} is {latex(amount_grams)}"
    options[
        3] = f"{name} made a total of {latex(left_c + given_c +1)} containers and the total weight of the {food} is {latex(amount_grams+food_capacity)}"

    options = random.sample(options, len(options))  #shuffiling all the options

    #findig the correct answer index, added a extra space in the correct string
    newOptionList = []
    for option in options:
        if option[-1] == ' ':
            correct_index = options.index(option)
        else:
            newOptionList.append(option)

    solution = f""""
    <br/>Here is the correct detailed solution
    <br/>Let's suppose the total number of containers to be {latex('X')}
    <br/>We know that total containers = containers given + containers left with her
    <br/>That is, {latex('X')} = containers  given + containers left
    <br/>{latex('X')} = {latex(given_c)} + {latex(left_c)}
    <br/>Hence, the total number of containers = {latex(total_c)}
    <br/>As we know that one container contains {latex(food_capacity)} gm of {food}, 
    <br/>Therefore, {latex(total_c)} will contain {latex(total_c)}*{latex(food_capacity)}
    <Hence, the total number of containers is {latex(total_c)} and total weight of {food} is {latex(amount_grams)} grams"""
    Question = ques
    Corr_op = options[correct_index]
    wrong_op1, wrong_op2, wrong_op3 = newOptionList
    Solution = solution

    database_dict = database_fn(Answer_Type='1',
                                Topic_Number='030202',
                                Variation=v3_13,
                                Question=Question,
                                Correct_Answer_1=Corr_op,
                                Wrong_Answer_1=wrong_op1,
                                Wrong_Answer_2=wrong_op2,
                                Wrong_Answer_3=wrong_op3,
                                ContributorMail='*****@*****.**',
                                Solution_text=Solution)
    return database_dict
示例#18
0
    def easy():
        r1 = random.randint(2, 12)
        if r1 % 2 != 0:
            r1 = r1 + 1
        r2 = random.randint(4, 21)
        if r2 % 2 != 0:
            r2 = r2 + 1
        r3 = random.randint(21, 35)
        if r3 % 2 != 0:
            r3 = r3 + 1
        r1 = 2
        y = (r3 + r2)
        x = y / r1

        ques = "Solve for x, " + latex(
            str(r1) + "x - " + str(r2) + " = " + str(r3))

        op = [0, 0, 0, 0]
        sq = [0, 1, 2, 3]
        o1 = ((r3 - r2) / r1)
        o2 = (r2 + r3 - r1) * (-1)
        o3 = x
        o4 = (r3 + r2) * r1
        ra = random.randint(0, 3)
        op[ra] = o3
        sq.remove(ra)
        op[sq[0]] = o1
        op[sq[1]] = o2
        op[sq[2]] = o4
        for i in range(1, 5):
            print(i, ". ", op[i - 1])
        print(" option 1 : ", int(o1), "\n", "option 2 : ", int(o2), "\n",
              "option 3 : ", int(o3), "\n", "option 4 : ", int(o4), "\n")

        def sol():
            sol1 = "solution: \n"
            sol1 = sol1 + latex(str(r1) + "x - " + str(r2) + " = " +
                                str(r3)) + "\n"
            sol1 = sol1 + latex(str(r1) + "x = " + str(r3) + " + " + str(
                r2)) + " (adding " + str(r2) + " to both sides)" + "\n"
            sol1 = sol1 + latex(str(r1) + "x = " + str(y)) + "\n"
            sol1 = sol1 + latex("x = ") + to_frac(str(y), str(
                r1)) + " (dividing by " + str(r1) + " in both sides)" + "\n"
            sol1 = sol1 + latex("x = " + str(x))
            return sol1

        solution = sol()
        Question = ques
        Corr_op = op[ra]
        wrong_op1, wrong_op2, wrong_op3 = op[sq[0]], op[sq[1]], op[sq[2]]
        Solution = solution
        database_dict = database_fn("text",
                                    Answer_Type='1',
                                    Topic_Number='030203',
                                    Variation='v2',
                                    Question=Question,
                                    Correct_Answer_1=Corr_op,
                                    Wrong_Answer_1=wrong_op1,
                                    Wrong_Answer_2=wrong_op2,
                                    Wrong_Answer_3=wrong_op3,
                                    Solution_text=solution)
        return database_dict
        value = int(input("Choose one option : "))
        if value == 1:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        elif value == 2:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        elif value == 3:
            print("\nright option")
            print(">--------------------------<")
            sol()
        elif value == 4:
            print("\nwrong option")
            print(">--------------------------<")
            sol()
        else:
            print("\nInvalid Choice")
示例#19
0
def substraction():
    r1 = random.randint(2, 12)
    if r1 % 2 != 0:
        r1 = r1 + 1
    r2 = random.randint(4, 21)
    if r2 % 2 != 0:
        r2 = r2 + 1
    r3 = random.randint(0, 35)
    if r3 % 2 != 0:
        r3 = r3 + 1
    y = (r2 - r3)
    x = y / r1

    ques = "Solve for x, " + latex(
        str(r2) + " - " + str(r1) + "x = " + str(r3))
    op = [0, 0, 0, 0]
    sq = [0, 1, 2, 3]
    o1 = ((r3 - r2) / r1)
    o2 = (r2 + r3 - r1)
    o3 = x
    o4 = (r3 + r2) * r1
    ra = random.randint(0, 3)
    op[ra] = o3
    sq.remove(ra)
    op[sq[0]] = o1
    op[sq[1]] = o2
    op[sq[2]] = o4
    for i in range(1, 5):
        print(i, ". ", op[i - 1])
    #print(" option 1 : ","%.3f" % o1,"\n","option 2 : ",o2,"\n","option 3 : ",o3,"\n","option 4 : ",o4,"\n")

    def sol():
        sol1 = "solution: \n"
        sol1 = sol1 + latex(str(r2) + " - " + str(r1) + "x = " +
                            str(r3)) + "\n"
        sol1 = sol1 + latex(
            str(r2) + " - " + str(r3) + " = " + str(r1) + "x"
        ) + " (taking constants in LHS and variable terms in RHS)" + "\n"
        sol1 = sol1 + latex(str(r1) + "x = " + str(y)) + "\n"
        sol1 = sol1 + latex("x = ") + to_frac(
            str(y),
            str(r1)) + "(dividing by " + str(r1) + " in both sides)" + "\n"
        sol1 = sol1 + latex("x = " + str(x)) + "\n"
        return sol1

    solution = sol()
    Question = ques
    Corr_op = op[ra]
    wrong_op1, wrong_op2, wrong_op3 = op[sq[0]], op[sq[1]], op[sq[2]]
    Solution = solution
    database_dict = database_fn("text",
                                Answer_Type='1',
                                Topic_Number='030203',
                                Variation='v9',
                                Question=Question,
                                Correct_Answer_1=Corr_op,
                                Wrong_Answer_1=wrong_op1,
                                Wrong_Answer_2=wrong_op2,
                                Wrong_Answer_3=wrong_op3,
                                Solution_text=solution)
    return database_dict

    value = int(input("Choose one option : "))

    if value == ra + 1:
        print("\nright option")
        print(">--------------------------<")
        sol()
    elif value != ra and value < 5 and value > 0:
        print("\nwrong option")
        print(">--------------------------<")
        sol()
    else:
        print("invalid choice")
    '''elif value==2: