Example #1
0
def substraction():
    #x - 3 = 5,solve for x
    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():
            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='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
        #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:
            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")'''

    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")

    print("1.easy")
    print("2.hard")
    ch = int(input("choose level:"))
    if ch == 1:
        putInCsv('030203', 10, easy, "v1_2")
    elif ch == 2:
        putInCsv('030203', 10, hard, "v1_1")
    else:
        print("invalid choice")
Example #2
0
    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")
            #return
main()
putInCsv(
                '030101',
                20,
                main,
                "v5_1"
                )
Example #3
0
def division():
    #solve for x, 15/x = 3
    def easy():
        r1 = random.randint(2, 21)
        r2 = random.randint(1, 10)
        r3 = r1 * r2
        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='v7',
                                    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 : ", "%.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")

    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")

    print("1.easy")
    print("2.hard")
    ch = int(input("choose level:"))
    if ch == 1:
        putInCsv('030203', 20, easy, "v1_7")
    elif ch == 2:
        putInCsv('030203', 20, hard, "v1_8")
    else:
        print("invalid choice")
Example #4
0
            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


putInCsv('030203',
         10,
         main_function,
         'v18_1',
         Remove_Duplicates=True,
         Create_Textfile=True)
Example #5
0
    else:
        section4 = '''\n<br>Since both expressions give different values, the answer is False'''
        print(section4)
    solution = section1 + section2 + section3 + section4
    return solution


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


putInCsv(Topic_Number='030102',
         Number_Of_Iterations=10,
         Main_Function=main,
         Filename=__file__)
Example #6
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")


addition()
putInCsv('03020101', 10, addition, "v1_1")
Example #7
0
    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")
main()

putInCsv('030102', 20, main, "v1_1", Remove_Duplicates=False)
Example #8
0
        print(">--------------------------<")
        sol()
    elif value == 3:
        print("\nright option")
        print(">--------------------------<")
        sol()
    elif value == 4:
        print("\nwrong option")
        print(">--------------------------<")
        sol()
    else:
        print("\nInvalid Choice")


#----main-----
while 1:
    print(">------------NEW QUESTION-------------<\n")
    print("1.Addition")
    print("2.Substraction")
    print("3.Division")
    ch = int(
        input("choose the relation between constant and the variable term:"))
    if ch == 1:
        putInCsv('030203', 20, addition, "v1_10")
    elif ch == 2:
        putInCsv('030203', 20, substraction, "v1_9")
    elif ch == 3:
        putInCsv('030203', 20, division, "v1_11")
    else:
        print("invalid choice")
Example #9
0
    return solution


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


putInCsv(Topic_Number='030201',
         Number_Of_Iterations=10,
         Main_Function=main,
         Filename=__file__,
         Remove_Duplicates=False)
Example #10
0
    <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


putInCsv(Topic_Number='030202',
         Number_Of_Iterations=20,
         Main_Function=main_function,
         Filename="v3_13")
Example #11
0
    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
putInCsv(
                '030101',
                10,
                main,
                "v3_1",
                Create_Textfile=True,
                Remove_Duplicates=True
                )
Example #12
0
        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


questionType = 0
solutionWord = ""
selectedTimeWord = ""

# CSV variables
question = ""
correctAnswer1 = ""
wrongAnswer1 = ""
wrongAnswer2 = ""
wrongAnswer3 = ""
solutionText = ""

lhsConst = 0
rhsConst = 0
putInCsv(Topic_Number='030202',
         Number_Of_Iterations=10,
         Main_Function=main,
         Filename='v1_1')
Example #13
0
        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


putInCsv(
    Topic_Number='030203',
    Number_Of_Iterations=15,
    Main_Function=main_function,
    Filename='v3_14')
Example #14
0
        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


putInCsv('030101',
         10,
         main_function,
         'v2_1',
         Create_Textfile=True,
         Remove_Duplicates=True)