示例#1
0
文件: v4_1.py 项目: mkale42/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"
    ]
    #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 = "If " + cop + ", will it form an equation? - True or False ? \n"
    #print("1.True \n2.False")
    #val=int(input("\nChoose a option : "))
    if cop in eq:
        Solution = "If " + cop + ", it will not form an equation because in this situation the LHS will not be equal to RHS"
        Corr_op = "False"
        wrong_op1 = "True"
    #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=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
示例#2
0
def main_function():
    arr1 = ['a', 'b', 'c', 'm', 'n', "x", "y", 'z']
    variable = latex(random.choice(arr1))
    solu = "\n-----------------SOLUTION--------------------- \n Since we do not know the exact number of " + str(
        item) + " with " + str(n1) + " and " + str(
            n2) + " let us use letter " + str(
                variable) + " to represent unknown quantity of " + str(
                    item) + " with " + str(n1)
    solu = solu + " and since " + str(n2) + " holds equal no. of " + str(
        item) + " we can represent number of " + str(
            item) + " 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
示例#3
0
def multiplication():
    r1 = random.randint(2, 10)  # consts
    r2 = random.choice(("a", "b", "c", "x", "y", "z"))  # variable
    r3 = random.randint(20, 30)  # rhs const

    sol = r3 / r1  #correct ans
    sol1 = r3 // r1
    op = sol1  #option displayed

    if op == sol:
        ans = "Yes"  #actual answer (yes/no)
        wrong_ans = "No"
    else:
        ans = "No"
        wrong_ans = "Yes"

    eqn = latex(str(r1) + r2 + " = " + str(r3))

    # Question
    ques = "For the equation " + str(eqn) + ", is the value of " + latex(
        r2 + " = " + str(op)) + " ? (Yes/No)"
    print(ques)

    def sol():
        sol1 = latex(str(r1) + r2 + " = " + str(r3)) + "\n"
        sol1 = sol1 + latex(
            to_frac(str(r1) + r2, str(r1)) + " = " + to_frac(str(r3), str(r1))
        ) + "            (Dividing " + str(r1) + " on both sides)" + "\n"
        sol1 = sol1 + latex(r2 + " = " + to_frac(str(r3), str(r1))) + "\n"
        sol1 = sol1 + latex(r2 + " = " + str(r3 / r1))
        return sol1

    print(sol())
    Solution = sol()
    Corr_op = ans
    wrong_op1 = wrong_ans
    Question = ques
    wrong_op2, wrong_op3 = "", ""
    database_dict = database_fn("text",
                                Answer_Type='1',
                                Topic_Number='030203',
                                Variation='v2',
                                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 = str(input("Enter Yes/No: "))  #input answer
    if value.capitalize() == ans:
        print("\nRight option!")
        print(">---------------------------<")
        sol()

    else:
        print("\nWrong Option!")
        print(">---------------------------<")
        sol()
示例#4
0
def subtraction():
    r1 = random.randint(20,50)
    r2 = random.randint(2,20)
    r3 =random.choice(("a","b","c","x","y","z"))
    ques="Ques. The difference obtained by subtracting "+num2words(r1)+" from certain number is "+num2words(r2)+",represent in equation "
    sol = latex(r3+" - "+str(r1)+" = "+str(r2))
    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(r3)+"="+str(r2)))#11-x=6
    op[sq[1]]=latex(str(str(r2)+" - "+str(r3)+" = "+str(r1)))#6-x=11
    op[sq[2]]=latex(str(str(r3)+" - "+str(r2)+" = "+str(r1)))#x-6=11
    for i in range(1,5):
        print(i,". ",op[i-1])

    

    def sol():
        sol1="Let's say certain number is :"+latex(str(r3))+"\n"
        sol1=sol1+"Difference is subtraction"+"\n"
        sol1=sol1+"Constant terms are : "+latex(str(r1))+" and "+latex(str(r2))+"\n"
        sol1=sol1+"Solution would be : "+latex(str(r3+" - "+str(r1)+" = "+str(r2)))
        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='v2',
    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("\n Right Option")
            print(">--------------------------------<")
            sol()
    elif value !=ra+1 and value<5 and value > 0:
            print("\n Wrong Option")
            print(">--------------------------------<")
            sol()
    else:
            print("Invalid Choice")
示例#5
0
def main():
    print("Ques. Which of the following is an equation ?")
    ques = "Which of the following is an equation ?"
    op = [0, 0, 0, 0]
    sq = [0, 1, 2, 3]
    ra = random.randint(0, 3)
    op[ra] = equi()
    sq.remove(ra)
    op[sq[0]] = notequi()
    op[sq[1]] = num()
    op[sq[2]] = line()
    for i in range(1, 5):
        print(i, ". ", op[i - 1])

    def sol():
        sol = "Solution:"
        sol = sol + "Equation can be defined as a mathematical statement \nin which two expressions are set equal to each other"
        sol = sol + "In option => " + op[ra]
        sol = sol + "=> " + latex(str(varx)) + " is the variable and " + latex(
            str(x1)) + latex(str(varx)) + " is the variable term"
        sol = sol + "=> " + latex(str(y2)) + " and " + latex(
            str(c3)) + " are the constant terms"
        return 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='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
    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():
    global question, correctAnswer1, wrongAnswer1, wrongAnswer2, wrongAnswer3, solutionText
    global lhsConst, rhsConst
    lhsConst = rd.randint(1, 24)
    rhsConst = rd.randint(25, 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
示例#7
0
def main_function():
    changequestion()
    Question = getQuestion()
    Corr_op = getCorrOption()
    wrong_op1, wrong_op2, wrong_op3 = getWrongOptions()
    Solution = soln()

    database_dict = database_fn(Answer_Type='text',
                                Topic_Number='030102',
                                Variation=7,
                                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
示例#8
0
文件: v1_4.py 项目: shubhra-jena/coep
def main():
    e0, e1 = generate_expression()
    name, p, e, key = print_questions([e0, e1])
    correct_option = print_options([e0, e1])
    #take_input(correct_option)
    print_solution([e0, e1, name, p, e, key])

    database_dict = database_fn(Answer_Type='1',
                                Topic_Number='030202',
                                Variation='v1',
                                Question=Question,
                                Correct_Answer_1=Correct_op,
                                Wrong_Answer_1=Wrong_op1,
                                Wrong_Answer_2=Wrong_op2,
                                Wrong_Answer_3=Wrong_op3,
                                ContributorMail='*****@*****.**',
                                Solution_text=Solution)
    return database_dict
示例#9
0
文件: v1.py 项目: sristis0202/demo
def main_function():
    question = getQuestion()
    CorrectAnswer1= getCorrectAnswer()
    Wrong_Answer_1, Wrong_Answer_2, Wrong_Answer_3 = getWrongAnswers()
    solution = sol()

    database_dict = database_fn(Answer_Type='text',
                        Topic_Number='030101',
                        Variation='1',
                        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=solution
                    )

    return database_dict
示例#10
0
文件: v2_1.py 项目: shubhra-jena/coep
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='1',
        Topic_Number='030102',
        Variation='v2',
        Question=Question,
        Correct_Answer_1=corr_op,
        Wrong_Answer_1=wrong_op,
        Solution_text=Solution
    )
    return database_dict
示例#11
0
def main_function():

    Question = getQuestion()
    Corr_op = getCorrOption()
    wrong_op1, wrong_op2, wrong_op3 = getWrongOptions()
    Solution = getSolution()

    #this database_fn
    #for understanding the parameters used refer to the DST_Lot_2 Excel sheet shared in the Readme file
    #all the attributes mentioned in DST_lot_2 file are implemented in this function.
    database_dict = database_fn(Answer_Type='1',
                                Topic_Number='01010101',
                                Variation='v1',
                                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
示例#12
0
def main():
    rows = generate_table()
    Question, corr_op = print_questions(rows)
    options_str, optn = print_options(corr_op)
    Solution = print_solution(rows, corr_op)

    optn.remove(corr_op)
    correct_option_string = format_dict(corr_op)
    wop1, wop2, wop3 = get_formatted_options(optn)

    database_dict = database_fn(Answer_Type='1',
                                Topic_Number='030102',
                                Variation='v9',
                                Question=Question,
                                Correct_Answer_1=correct_option_string,
                                Wrong_Answer_1=wop1,
                                Wrong_Answer_2=wop2,
                                Wrong_Answer_3=wop3,
                                Solution_text=Solution)
    return database_dict
示例#13
0
def main_function():
    changeGlobals()
    question = getQuestion()
    Correct_Answer_1 = getCorrectAnswer()
    Wrong_Answer_1, Wrong_Answer_2, Wrong_Answer_3 = getWrongAnswers()
    imagePath = generate_image()
    solution = sol()

    database_dict = database_fn(Answer_Type='text',
                                Topic_Number='030102',
                                Variation=5,
                                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,
                                Question_IAV=imagePath,
                                ContributorMail='*****@*****.**',
                                Solution_text=solution)

    return database_dict
示例#14
0
文件: v4_1.py 项目: shubhra-jena/coep
def main_function():
    changeGlobals()
    question = getQuestion()
    CorrectAnswer1 = getCorrectAnswer()
    Wrong_Answer_1 = getWrongAnswer()
    imagePath = generateImage()
    solution = sol()

    database_dict = database_fn(
        Question_Type='image',
        Answer_Type='text',
        Topic_Number='030102',
        Variation=4,
        Question=question,
        Correct_Answer_1=CorrectAnswer1,
        Wrong_Answer_1=Wrong_Answer_1,
        Question_IAV=imagePath,
        ContributorMail='*****@*****.**',
        Solution_text=solution)

    return database_dict
示例#15
0
文件: v1_3.py 项目: surajmoolya/coep
def newMain():
    var1, var2, object, name, variable, key = generate_expression()
    question = print_expression(var1, var2, object, name, variable, key)
    option = generate_options()
    #print(option)
    c_ans, w_ans1, w_ans2, w_ans3 = print_option(option[0], option[1],
                                                 option[2], option[3], var1,
                                                 var2, variable)
    solution = generate_solution(var1, var2, object, name, variable, key)
    # print(solution)

    database_dict = database_fn(Answer_Type='text',
                                Topic_Number='030202',
                                Variation='v1',
                                Question=question,
                                Correct_Answer_1=c_ans,
                                Wrong_Answer_1=w_ans1,
                                Wrong_Answer_2=w_ans2,
                                Wrong_Answer_3=w_ans2,
                                ContributorMail='*****@*****.**',
                                Solution_text=solution)
    return database_dict
示例#16
0
def main_function():
    change_globals()
    eq=["If "+n1+" has "+str(r1)+i+" and "+n2+" has "+str(r2)+i+" then "+n2+" has "+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 "+n1+" has "+str(r4)+i+" and "+n2+" has "+str(r5)+i+" then "+n2+" has "+str(r6)+i+" more than "+n1]
    nteq=["If "+n1+" has "+str(r1)+i+" and "+n2+" has "+str(r2)+i+" then "+n2+" has 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 2 Kg  rice on one side and 1 Kg sugar on the other side","If "+n1+" has "+str(r4)+i+" and "+n2+" has "+str(r5)+i+" then "+n2+" has "+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.\n"

    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=("Since, we know that, 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 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+("<br/>Therefore, according to the 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=("Since, we know that, 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 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+("<br/>Therefore, according to the question, LHS is 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='1',
    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            
示例#17
0
def main_function():

    n1 = randomMarathi()
    n2 = randomMarathi()

    r2 = random.randint(1, 5)
    r9 = random.randint(2, 7)
    if r2 % r9 == 0:
        r9 = r9 + 1
    if r2 > r9:
        r2, r9 = r9, r2

    r10_latex = latex(to_frac(str(r2), str(r9)))
    r10 = Fraction(r2, r9)
    r1 = random.randint(10, 60)

    #option 4
    c = (r1) / (r10 + 1)
    d = c * r10

    #option 1
    r3 = random.randint(10, 30)
    #options should not be same
    if r3 == c or r3 == d:
        r3 = r3 + 1

    r4 = abs(r1 - r3)

    if r3 == r1:
        r3 = r3 - 15
        r4 = 15

    #option 2
    r5 = random.randint(10, 30)
    #options should not be same
    if r5 == c:
        r5 = r5 + 1

    r6 = r10 * r5

    #option 3
    r7 = d
    r8 = c

    items = [
        'Lemonade', 'Tea', 'Coffee', 'Milk', 'Orange juice', 'Mango juice',
        'water', 'Soup', 'Soft drink', 'Oil', 'Apple juice'
    ]

    i = random.choice(items)

    temp1 = n1 + ' and ' + n2 + ' have a total of ' + str(
        r1) + ' litres of ' + i + '. '

    r = random.randint(1, 5)
    if r > 3:
        n1, n2 = n2, n1

    temp2 = 'If ' + n2 + ' has ' + str(
        r10_latex
    ) + ' times the ' + i + ' that ' + n1 + ' has, how many litres of ' + i + ' does each one have?\n'

    question = temp1 + temp2
    print(question)

    op = ["", "", "", ""]
    sq = [0, 1, 2, 3]
    #option variables
    o1 = n1 + ''' has ''' + latex(str((
        r3))) + ''' litres of ''' + i + ''' and ''' + n2 + ''' has ''' + latex(
            str((r4))) + ''' litres of ''' + i
    o2 = n1 + ''' has ''' + latex(str((
        r5))) + ''' litres of ''' + i + ''' and ''' + n2 + ''' has ''' + latex(
            str((r6))) + ''' litres of ''' + i
    o3 = n1 + ''' has ''' + latex(str(
        (c))) + ''' litres of ''' + i + ''' and ''' + n2 + ''' has ''' + latex(
            str((d))) + ''' litres of ''' + i
    o4 = n1 + ''' has ''' + latex(str((
        r7))) + ''' litres of ''' + i + ''' and ''' + n2 + ''' has ''' + latex(
            str((r8))) + ''' litres of ''' + 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 : "))

    #solution function
    def sol():
        sol = ('''let ''' + n1 + ''' has ''' + latex('x') + ''' litres of ''' +
               i + '''.
    <br/>Since, ''' + n2 + ''' has ''' + (r10_latex) + ''' times the ''' + i +
               ''' that ''' + n1 + ''' has
        <br/>Therefore, ''' + n2 + ''' will have (''' + r10_latex + ''')* ''' +
               latex('x') + ''' litres of ''' + i + '''.  
    <br/>Since, ''' + n1 + ''' and ''' + n2 + ''' have a total of ''' +
               latex(str(r1)) + ''' litres of ''' + i + '''
        <br/>=>''' + latex('''x+(''') + r10_latex +
               latex(''')*x=''' + str(r1)) + '''       
        <br/>Taking ''' + latex('x') +
               ''' common from both the terms in L.H.S :-
        <br/>=> ''' + latex('''(1+''') + r10_latex +
               latex(''')*x=''' + str(r1))) + "\n"
        sol = sol + (" <br/>   => " +
                     latex("(" + to_frac(str(r2 + r9), str(r9)) + ")* x =" +
                           str(r1))) + "\n"
        a = r10 + 1
        sol = sol + ("<br/>Dividing both the sides by " +
                     latex(to_frac(str(r2 + r9), str(r9)))) + "\n"
        sol = sol + (" <br/>   => " +
                     latex("x=" + to_frac(str(r1), str(a)))) + "\n"
        sol = sol + (" <br/>   => " + latex("x=" + str(r1 / a))) + "\n"
        b = Fraction((r2 + r9), (r9))
        sol = sol + (" <br/>   => " + latex("(") + r10_latex +
                     latex(")*x = (") + r10_latex +
                     latex(")*(" + to_frac(str(r1), str(b)) + ")=" + str(
                         (r1 / a) * r10))) + "\n"
        sol = sol + ('<br/>Hence, ' + n1 + ' has ' + latex(str(
            (r1 / a))) + ' litres of ' + i + ' and ' + n2 + ' has ' +
                     latex(str(
                         ((r1 / a) * r10))) + ' litres of ' + i + ' ') + "\n"

        return sol

    if value == ra + 1:
        print("\nYour answer is Correct!")
        print(">------------- SOLUTION -------------<")
        print(sol())
    elif value != ra + 1 and value < 5 and value > 0:
        print("\nYour answer is incorrect!")
        print(">------------- SOLUTION --------------<")
        print(sol())
    else:
        print("invalid choice")

    database_dict = database_fn(Answer_Type='1',
                                Topic_Number='030203',
                                Variation='v3_12',
                                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
示例#18
0
    def hard():
        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 = (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)
        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])

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

        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='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
        #print(" option 1 : ","%.3f" % o1,"\n","option 2 : ",o2,"\n","option 3 : ",o3,"\n","option 4 : ",o4,"\n")

        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")
        '''elif value==2:
示例#19
0
def main_function():

    n1 = randomMarathi()
    n2 = randomMarathi()

    r2 = random.randint(1, 20)
    if r2 % 2 != 0:
        r2 = r2 + 1

    r1 = random.randint(45, 100)
    if r1 % 2 != 0:
        r1 = r1 + 1

    #option 4
    c = (r1 + r2) / 2
    d = c - r2

    #option 1
    r3 = random.randint(25, 40)
    #options should not be same
    if r3 == c or r3 == d:
        r3 = r3 + 1

    r4 = abs(r1 - r3)

    if r3 == r1:
        r3 = r3 - 15
        r4 = 15

    #option 2
    r5 = random.randint(22, 50)
    #options should not be same
    if r5 == c:
        r5 = r5 + 1

    r6 = r5 - r2

    #option 3
    r7 = d
    r8 = c

    items = [
        'Apples', 'books', 'pens', 'sheets', 'toys', 'candies', 'pencils',
        'shirts', 'pants', 'T-shirts', 'Jackets', 'Bananas', 'chocolates',
        'Watermelons', 'Cookies'
    ]

    i = random.choice(items)

    temp1 = n1 + ' and ' + n2 + ' have a total of ' + str(r1) + ' ' + i + '.'

    r = random.randint(1, 5)
    if r > 3:
        n1, n2 = n2, n1

    temp2 = 'If ' + n2 + ' has ' + str(
        r2
    ) + '' + i + 'less than ' + n1 + ', how many ' + i + ' does each one have?\n'

    question = temp1 + temp2
    print(question)

    op = ["", "", "", ""]
    sq = [0, 1, 2, 3]
    #option variables
    o1 = n1 + ''' has ''' + str(
        int(r3)) + ''' ''' + i + ''' and ''' + n2 + ''' has ''' + str(
            int(r4)) + ''' ''' + i
    o2 = n1 + ''' has ''' + str(
        int(r5)) + ''' ''' + i + ''' and ''' + n2 + ''' has ''' + str(
            int(r6)) + ''' ''' + i
    o3 = n1 + ''' has ''' + str(
        int(c)) + ''' ''' + i + ''' and ''' + n2 + ''' has ''' + str(
            int(d)) + ''' ''' + i
    o4 = n1 + ''' has ''' + str(
        int(r7)) + ''' ''' + i + ''' and ''' + n2 + ''' has ''' + str(
            int(r8)) + ''' ''' + 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 ''' + n1 + ''' has ''' + latex('x') + ''' ''' + i + '''.
    <br/>Since, ''' + n2 + ''' has ''' + latex(str(r2)) + ''' less ''' + i +
               ''' than ''' + n1 + '''
        <br/>Therefore, ''' + n2 + ''' will have ''' + latex('x') + '''-''' +
               latex(str(r2)) + ''' ''' + i + '''.
    <br/>Since, ''' + n1 + ''' and ''' + n2 + ''' have a total of ''' +
               str(r1) + ''' ''' + i + '''    
        <br/>=> ''' + latex('''x+(x-''' + str(r2) + ''')=''' + str(r1)) + '''  
        <br/>=> ''' + latex('''x+x-''' + str(r2) + '''=''' + str(r1)) + '''    
        <br/>=> ''' + latex('''2x-''' + str(r2) + '''=''' + str(r1)))

        sol = sol + ("<br/>=> " +
                     latex("2x=" + str(r1) + "+" + str(r2))) + "\n"
        a = r1 + r2
        sol = sol + ("<br/>Dividing both the sides by 2") + "\n"
        sol = sol + ("<br/>=> " + latex("x=" + to_frac(str(a), "2"))) + "\n"
        sol = sol + ("<br/>=> " + latex("x=" + str(int(a / 2)))) + "\n"
        sol = sol + ("<br/>=> " +
                     latex("x-" + str(r2) + "=" + str(int(a / 2)) + "-" +
                           str(r2) + "=" + str(int((a / 2 - r2))))) + "\n"
        sol = sol + ('<br/>Hence, ' + n1 + ' has ' + latex(str(int(a / 2))) +
                     ' ' + i + ' and ' + n2 + ' has ' +
                     latex(str(int((a / 2 - r2)))) + ' ' + i + ' ')

        return sol

    if value == ra + 1:
        print("\nYour answer is Correct!")
        print(">------------- SOLUTION -------------<")
        print(sol())
    elif value != ra + 1 and value < 5 and value > 0:
        print("\nYour answer is incorrect!")
        print(">------------- SOLUTION --------------<")
        print(sol())
    else:
        print("invalid choice")

    database_dict = database_fn(Answer_Type='1',
                                Topic_Number='030203',
                                Variation='v3_10',
                                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
示例#20
0
def multiplication():
    r1 = random.randint(2, 20)  #coeff
    r2 = random.choice(("a", "b", "c", "x", "y", "x"))  #variable
    r3 = random.randint(2, 30)  #rhs constant

    #Question
    ques = "Ques. The product of a certain number and " + num2words(
        r1) + " is " + num2words(r3) + ", represent in equation"

    solution = latex(str(r1) + r2 + "=" + str(r3))

    print(ques)
    #Option

    op = [0, 0, 0, 0]
    sq = [0, 1, 2, 3]
    ra = random.randint(0, 3)  #correct option
    op[ra] = solution
    sq.remove(ra)
    op[sq[0]] = latex(
        str(str(r3) + "*(" + str(r2) + "+" + str(r1) + ")" + "=" +
            str(r3)))  #addition 45*(z+15)+45
    op[sq[1]] = latex(
        str(str(r3) + "*(" + str(r1) + str(r2) + ")" + "=" +
            str(r3)))  #subtraction 45*(15z)=45
    op[sq[2]] = latex(str(str(r1) + str(r2) + "+" + str(r2) + "=" +
                          str(r3)))  #product + addition 15z+z=45
    for i in range(1, 5):
        print(i, ". " + op[i - 1])

    def sol():
        sol = "Let's assume the certain number to be: " + latex(str(r2)) + "\n"
        sol = sol + "Product means multiplication" + "\n"
        sol = sol + "Hence, the certain number " + latex(
            str(r2)) + " is to be multiplied by " + latex(str(r1)) + "\n"
        sol = sol + "Solution would be: " + latex(solution) + "\n"
        sol = sol + "Coefficient of " + latex(str(r2)) + " is: " + latex(
            str(r1)) + "\n"
        sol = sol + "Constant term is: " + latex(str(r3)) + "\n"
        return sol

    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='v3',
                                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!")
        sol()
    else:
        print("Invalid Choice!")
示例#21
0
def main_function():
    n1 = randomMarathi()

    r2 = random.randint(1, 35)

    r1 = random.randint(40, 100)

    #option1
    p1 = (r1 + r2 + 1)

    # option 2
    p2 = (r1 + r2)

    #Option 3
    p3 = abs(r1 - r2)

    #option 4
    p4 = abs(r1 - r2 - 1)

    items = [
        'Sheeps', 'books', 'pens', 'sheets', 'toys', 'candies', 'pencils',
        'shirts', 'pants', 'T-shirts', 'Jackets', 'Bananas', 'chocolates',
        'Watermelons', 'Cookies'
    ]

    i = random.choice(items)

    temp1 = n1 + ' has some ' + i + '. ' + n1 + ' sells ' + str(
        r2) + ' of them in the market and left with ' + str(r1) + ' ' + i

    r = random.randint(1, 5)

    temp2 = ' How many ' + i + ' ' + n1 + ' had initially ?.\n'

    question = temp1 + temp2

    print(question)

    op = ["", "", "", ""]
    sq = [0, 1, 2, 3]
    #option variables
    o1 = n1 + ''' had ''' + str(int(p1)) + ''' ''' + i
    o2 = n1 + ''' had ''' + str(int(p4)) + ''' ''' + i
    o3 = n1 + ''' had ''' + str(int(p2)) + ''' ''' + i
    o4 = n1 + ''' had ''' + str(int(p3)) + ''' ''' + 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 : "))
    """
        If we want solution using two variables then solution will be as follows 

        def sol():
        print('let',i,'sold in the market = x.\n' 'Total ' ,i, 'initially = y.')
        print('X + '+ str(r1) + ' = y.') 
        a = r2+r1
        print('y=',a)
        """
    def sol():
        sol = ('''Let us assume that the number of ''' + i + ''' with ''' +
               n1 + ''' at first be ''' + latex('x') + '<br/>' + n1 +
               ' sold ' + latex(str(r2)) + i + ' and left with ' +
               latex(str(r1)) + i + '<br/>' + ' Number of ' + i + ' left = '
               ' Number of ' + i + ' initially - '
               ' Number of ' + i + ' sold at the market ' + '<br/>' +
               ' Therefore,' + latex('x -' + str(r2) + ' = ' + str(r1)) + ' ' +
               '<br/>' + latex('x - ' + str(r2) + ' + ' + str(r2) + ' = ' +
                               str(r1) + ' + ' + str(r2)) + '   (Add ' +
               latex(str(r2)) + ' to both sides)')
        a = r1 + r2
        str1 = ' x + 0 =' + str(a)
        str2 = ' x = ' + str(a)
        sol = sol + '<br/>' + latex(str(str1))
        sol = sol + '<br/>' + latex(str(str2))
        sol = sol + '<br/> Thus, there were ' + latex(
            str(a)) + ' ' + i + ' with ' + n1 + ' at first'
        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='v3_15',
                                Topic_Number='030203',
                                Variation=7,
                                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
示例#22
0
def main_function():
    change_globals()
    x = random.randint(0, 5)
    #print(x)
    if x >= 0 and x <= 2:

        #Question
        question = "If " + n1 + " weighs " + latex(
            str(r1)) + " Kg and " + n2 + " weighs " + latex(
                str(r2)) + " Kg, " + n3 + " weighs " + latex(
                    str(r3)) + " Kg and " + n4 + " weighs " + latex(str(
                        r4)) + " Kg.\nWhich two pairs will form an equation?\n"
        print(question)

        op = ["", "", "", ""]
        sq = [0, 1, 2, 3]
        #options

        if r1 * r2 == r3 * r4:
            o3 = '''(''' + n1 + ''' , ''' + n2 + ''') and (''' + n3 + ''' , ''' + n4 + ''')'''
            o1 = '''(''' + n1 + ''' , ''' + n3 + ''') and (''' + n2 + ''' , ''' + n4 + ''')'''
            o2 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
            o4 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n5 + ''')'''
        elif r1 * r3 == r2 * r4:
            o3 = '''(''' + n1 + ''' , ''' + n3 + ''') and (''' + n2 + ''' , ''' + n4 + ''')'''
            o1 = '''(''' + n1 + ''' , ''' + n2 + ''') and (''' + n3 + ''' , ''' + n4 + ''')'''
            o2 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
            o4 = '''(''' + n1 + ''' , ''' + n5 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
        elif r1 * r4 == r2 * r3:
            o3 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
            o1 = '''(''' + n1 + ''' , ''' + n3 + ''') and (''' + n2 + ''' , ''' + n4 + ''')'''
            o2 = '''(''' + n1 + ''' , ''' + n2 + ''') and (''' + n3 + ''' , ''' + n4 + ''')'''
            o4 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n5 + ''' , ''' + n3 + ''')'''

        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 sol5():
            sol5 = ("Since, it is given that the weights of " + n1 + ", " +
                    n2 + ", " + n3 + " and " + n4 + "\nare " + latex(str(r1)) +
                    ", " + latex(str(r2)) + ", " + latex(str(r3)) + " and " +
                    latex(str(r4)) + " respectively") + "\n"
            if r1 * r2 == r3 * r4:
                a = r1 * r2
                b = r3 * r4
                sol5 = sol5 + (
                    "Now, " +
                    latex(str(r1) + " * " + str(r2) + " = " + str(a))) + "\n"
                sol5 = sol5 + (
                    "Also, " +
                    latex(str(r3) + " * " + str(r4) + " = " + str(b))) + "\n"
                sol5 = sol5 + ("=> " + latex(
                    str(r1) + " * " + str(r2) + " = " + str(r3) + " * " +
                    str(r4))) + "\n"
                sol5 = sol5 + ("=> L.H.S = R.H.S") + "\n"
                sol5 = sol5 + (
                    "As we know that,\nAn Equation is a mathematical statement consisting of an equal symbol between two expressions having the same value."
                ) + "\n"
                sol5 = sol5 + (
                    "Therefore, according to the question,\nThe two pairs which will form an equation are : "
                    + n1 + " and " + n2 + " , " + n3 + " and " + n4) + "\n"

            elif r1 * r3 == r2 * r4:
                a = r1 * r3
                b = r2 * r4
                sol5 = sol5 + (
                    "Now, " +
                    latex(str(r1) + " * " + str(r3) + " = " + str(a))) + "\n"
                sol5 = sol5 + (
                    "Also, " +
                    latex(str(r2) + " * " + str(r4) + " = " + str(b))) + "\n"
                sol5 = sol5 + ("=> " + latex(
                    str(r1) + " * " + str(r3) + " = " + str(r2) + " * " +
                    str(r4))) + "\n"
                sol5 = sol5 + ("=> L.H.S = R.H.S") + "\n"
                sol5 = sol5 + (
                    "As we know that,\nAn Equation is a mathematical statement consisting of an equal symbol between two expressions having the same value."
                ) + "\n"
                sol5 = sol5 + (
                    "Therefore, according to the question,\nThe two pairs which will form an equation are : "
                    + n1 + " and " + n3 + " , " + n2 + " and " + n4) + "\n"

            elif r1 * r4 == r2 * r3:
                a = r1 * r4
                b = r2 * r3
                sol5 = sol5 + (
                    "Now, " +
                    latex(str(r1) + " * " + str(r4) + " = " + str(a))) + "\n"
                sol5 = sol5 + (
                    "Also, " +
                    latex(str(r2) + " * " + str(r3) + " = " + str(b))) + "\n"
                sol5 = sol5 + ("=> " + latex(
                    str(r1) + " * " + str(r4) + " = " + str(r2) + " * " +
                    str(r3))) + "\n"
                sol5 = sol5 + ("=> L.H.S = R.H.S") + "\n"
                sol5 = sol5 + (
                    "As we know that,\nAn Equation is a mathematical statement consisting of an equal symbol between two expressions having the same value."
                ) + "\n"
                sol5 = sol5 + (
                    "Therefore, according to the question,\nThe two pairs which will form an equation are : "
                    + n1 + " and " + n4 + " , " + n2 + " and " + n3) + "\n"

            return sol5

        if value == ra + 1:
            print("\nYour answer is Correct!")
            print(">------------- SOLUTION -------------<")
            print(sol5())
        elif value != ra + 1 and value < 5 and value > 0:
            print("\nYour answer is incorrect!")
            print(">------------- SOLUTION --------------<")
            print(sol5())
        else:
            print("invalid choice")

    elif x > 2 and x <= 5:
        #Question
        question = "If " + n1 + " has " + latex(
            str(r1)) + " " + i + ", " + n2 + " has " + latex(
                str(r2)) + " " + i + ", " + n3 + " has " + latex(
                    str(r3)) + " " + i + " and " + n4 + " has " + latex(
                        str(r4)
                    ) + " " + i + ".\nWhich two pairs will form an equation?\n"
        print(question)
        op = ["", "", "", ""]
        sq = [0, 1, 2, 3]
        #options

        #(aarav, Gautami) and (Abhieet, Chaitrali)
        if r1 * r2 == r3 * r4:
            o3 = '''(''' + n1 + ''' , ''' + n2 + ''') and (''' + n3 + ''' , ''' + n4 + ''')'''
            o1 = '''(''' + n1 + ''' , ''' + n3 + ''') and (''' + n2 + ''' , ''' + n4 + ''')'''
            o2 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
            o4 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n5 + ''')'''
        elif r1 * r3 == r2 * r4:
            o3 = '''(''' + n1 + ''' , ''' + n3 + ''') and (''' + n2 + ''' , ''' + n4 + ''')'''
            o1 = '''(''' + n1 + ''' , ''' + n2 + ''') and (''' + n3 + ''' , ''' + n4 + ''')'''
            o2 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
            o4 = '''(''' + n1 + ''' , ''' + n5 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
        elif r1 * r4 == r2 * r3:
            o3 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n2 + ''' , ''' + n3 + ''')'''
            o1 = '''(''' + n1 + ''' , ''' + n3 + ''') and (''' + n2 + ''' , ''' + n4 + ''')'''
            o2 = '''(''' + n1 + ''' , ''' + n2 + ''') and (''' + n3 + ''' , ''' + n4 + ''')'''
            o4 = '''(''' + n1 + ''' , ''' + n4 + ''') and (''' + n5 + ''' , ''' + n3 + ''')'''

        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 sol6():
            sol6 = ("Since, it is given that the weights of " + n1 + ", " +
                    n2 + ", " + n3 + " and " + n4 + "\nare " + latex(str(r1)) +
                    ", " + latex(str(r2)) + ", " + latex(str(r3)) + " and " +
                    latex(str(r4)) + " respectively") + "\n"
            if r1 * r2 == r3 * r4:
                a = r1 * r2
                b = r3 * r4
                sol6 = sol6 + (
                    "Now, " +
                    latex(str(r1) + " * " + str(r2) + " = " + str(a))) + "\n"
                sol6 = sol6 + (
                    "Also, " +
                    latex(str(r3) + " * " + str(r4) + " = " + str(b))) + "\n"
                sol6 = sol6 + ("=> " + latex(
                    str(r1) + " * " + str(r2) + " = " + str(r3) + " * " +
                    str(r4))) + "\n"
                sol6 = sol6 + ("=> L.H.S = R.H.S") + "\n"
                sol6 = sol6 + (
                    "As we know that,\nAn Equation is a mathematical statement consisting of an equal symbol between two expressions having the same value."
                ) + "\n"
                sol6 = sol6 + (
                    "Therefore, according to the question,\nThe two pairs which will form an equation are : "
                    + n1 + " and " + n2 + " , " + n3 + " and " + n4) + "\n"

            elif r1 * r3 == r2 * r4:
                a = r1 * r3
                b = r2 * r4
                sol6 = sol6 + (
                    "Now, " +
                    latex(str(r1) + " * " + str(r3) + " = " + str(a))) + "\n"
                sol6 = sol6 + (
                    "Also, " +
                    latex(str(r2) + " * " + str(r4) + " = " + str(b))) + "\n"
                sol6 = sol6 + ("=> " + latex(
                    str(r1) + " * " + str(r3) + " = " + str(r2) + " * " +
                    str(r4))) + "\n"
                sol6 = sol6 + ("=> L.H.S = R.H.S") + "\n"
                sol6 = sol6 + (
                    "As we know that,\nAn Equation is a mathematical statement consisting of an equal symbol between two expressions having the same value."
                ) + "\n"
                sol6 = sol6 + (
                    "Therefore, according to the question,\nThe two pairs which will form an equation are : "
                    + n1 + " and " + n3 + " , " + n2 + " and " + n4) + "\n"

            elif r1 * r4 == r2 * r3:
                a = r1 * r4
                b = r2 * r3
                sol6 = sol6 + (
                    "Now, " +
                    latex(str(r1) + " * " + str(r4) + " = " + str(a))) + "\n"
                sol6 = sol6 + (
                    "Also, " +
                    latex(str(r2) + " * " + str(r3) + " = " + str(b))) + "\n"
                sol6 = sol6 + ("=> " + latex(
                    str(r1) + " * " + str(r4) + " = " + str(r2) + " * " +
                    str(r3))) + "\n"
                sol6 = sol6 + ("=> L.H.S = R.H.S") + "\n"
                sol6 = sol6 + (
                    "As we know that,\nAn Equation is a mathematical statement consisting of an equal symbol between two expressions having the same value."
                ) + "\n"
                sol6 = sol6 + (
                    "Therefore, according to the question,\nThe two pairs which will form an equation are : "
                    + n1 + " and " + n4 + " , " + n2 + " and " + n3) + "\n"

            return sol6

        if value == ra + 1:
            print("\nYour answer is Correct!")
            print(">------------- SOLUTION -------------<")
            print(sol6())
        elif value != ra + 1 and value < 5 and value > 0:
            print("\nYour answer is incorrect!")
            print(">------------- SOLUTION --------------<")
            print(sol6())
        else:
            print("invalid choice")

    if x >= 0 and x <= 2:
        sol = sol5()

    elif x > 2 and x <= 5:
        sol = sol6()

    database_dict = database_fn(Question_Type='text',
                                Answer_Type='1',
                                Topic_Number='030102',
                                Variation=3,
                                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
示例#23
0
def multiplication():
    r1 = random.randint(10, 30)  # consts
    r2 = random.choice(("a", "b", "c", "x", "y", "x"))  # variable
    r3 = random.randint(2, 10)  # rhs const

    sol = r3 * r1  #correct ans

    op = random.choice((sol, (sol * r3), (sol * r1), (sol + r3),
                        (sol + r1)))  #option displayed

    if op == sol:
        ans = "Yes"  #actual answer (yes/no)
        wrong_ans = "No"
    else:
        ans = "No"
        wrong_ans = "Yes"

    eqn = latex(r2 + " / " + str(r1) + " = " + str(r3))

    # Question
    ques = "For the equation, " + latex(str(eqn)) + " is the value of ", latex(
        r2), "=", latex(op), "? (Yes/No)"
    print(ques)

    def sol():
        sol1 = latex(r2 + " / " + str(r1) + " = " + str(r3)) + "\n"
        sol1 = sol1 + latex("( " + r2 + " / " + (str(r1)) + " )" + " * " +
                            str(r1) + " = " + str(r3) + " * " + str(r1) +
                            "             (Multiplying " + str(r1) +
                            " on both sides)") + "\n"
        sol1 = sol1 + latex(r2 + " = " + str(r3) + " * " + str(r1)) + "\n"
        sol1 = sol1 + latex(r2 + " = " + str(r3 * r1))
        return sol1

    print(sol())
    Solution = sol()
    Corr_op = ans
    wrong_op1 = wrong_ans
    Question = ques
    wrong_op2, wrong_op3 = "", ""

    database_dict = database_fn("text",
                                Answer_Type='1',
                                Topic_Number='030203',
                                Variation='v2',
                                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 = str(input("Enter Yes/No: "))  #input answer

    if (value.capitalize() == ans):
        print("\nRight answer!")
        print(">---------------------------<")
        sol()

    else:
        print("\nWrong answer!")
        print(">---------------------------<")
        sol()
示例#24
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"
            )
示例#25
0
def subtraction():
    r1 = random.randint(2, 20)  # consts (3)
    r2 = random.choice(("a", "b", "c", "x", "y", "x"))  # variable (y)
    r3 = random.randint(2, 30)  # rhs const (11)

    sol = r3 + r1  #correct ans (11+3 = 14)

    op = random.randint(sol - 1, sol + 2)  #option displayed

    if op == sol:
        ans = "Yes"  #actual answer (yes/no)
        wrong_ans = "No"
    else:
        ans = "No"
        wrong_ans = "Yes"

    eqn = latex(r2 + " - " + str(r1) + " = " + str(r3))  #y-3=11

    # Question
    ques = "For the equation " + str(eqn) + ", is the value of " + latex(
        r2 + "=" + str(op) + "? (Yes/No)") + "\n"
    print(ques)

    def sol():
        sol1 = latex(str(r2) + " - " + str(r1) + " = " + str(r3) + "\n")
        sol1 = sol1 + latex(
            str(r2) + " - " + str(r1) + " + " + str(r1) + " = " + str(r3) +
            " + " + str(r1) + "             (Adding " + str(r1) +
            " on both sides)" + "\n")
        sol1 = sol1 + latex(str(r2) + " = " + str(r3 + r1) + "\n")
        return sol1

    print(sol())
    Solution = sol()
    Corr_op = ans
    wrong_op1 = wrong_ans
    Question = ques
    wrong_op2, wrong_op3 = "", ""
    database_dict = database_fn("text",
                                Answer_Type='1',
                                Topic_Number='030203',
                                Variation='v2',
                                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 = str(input("Enter Yes/No: "))  #input answer

    if value.capitalize() == ans:
        print("\nRight option!")
        print(">---------------------------<")
        sol()

    else:
        print("\nWrong Option!")
        print(">---------------------------<")
        sol()
示例#26
0
def division():
    r1 = random.randint(2, 30)  #coeffiecient
    r2 = random.choice(("a", "b", "c", "x", "y", "x"))  #variable
    r3 = random.randint(1, 10)
    ques = "Quotient of a certain dividend having " + num2words(
        r1) + " as a divisor, is " + num2words(r3) + "\n"
    ques = ques + "Represent the following in the form of an 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)  #correct option
    op[ra] = sol
    sq.remove(ra)
    op[sq[0]] = latex(str(str(r2) + "/" + str(r3)) + "=" + str(r1))
    op[sq[1]] = latex(str(str(r1) + "/" + str(r3)) + "=" + str(r2))
    op[sq[2]] = latex(str(str(r1) + "/" + str(r2)) + "=" + 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 + "For finding the Dividend, we need to perform division operation" + "\n"
        sol1 = sol1 + "Divisor : " + latex(
            str(r1)) + " and Quotient : " + latex(str(r3)) + "\n"
        sol1 = sol1 + "Solution would be : " + latex(
            str(r2) + " / " + str(r1) + " = " + str(r3))
        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")