PYthon Simple Contact – Wrong Question Book Program

This program is designed with the help of the pycharm platform. Its main function is to mark and review wrong questions into the database. The interface is divided into two major sections, each corresponding to seven categories of questions. The wrong question storage section mainly extracts the photo of the question and enters the difficulty as a mark. Store the photos of the questions and answers in the corresponding folders, and store the address information in the MYSQL database; the question review is to select four questions of different difficulty from the question bank based on the marks, and compare the answers to determine whether they are right or wrong. Realize the increase or decrease of the difficulty mark of the questions to achieve the effect of review of the questions

The following is part of the code: (for reference only)

 def add_higher_mathematics_grade(self):
        import mysql.connector
        global questions_grade
        global questions_name
        questions_grade = str(questions_grade).replace('[', '').replace(']', '').replace("'", "")
        questions_grade = int(questions_grade)
        print(questions_grade)
        print(questions_name)
        questions_grade = questions_grade + 1
        questions_grade = str(questions_grade)
        questions_name = str(questions_name)
        renew_question = mysql.connector.connect(
            host="localhost",
            user="root",
            passwd="dxy123",
            db='study'
        )
        mycursor = renew_question.cursor()
        mysql= 'update high number set tag=%s where question number=%s'
        information=(questions_grade,questions_name)
        mycursor.execute(mysql,information)
        renew_question.commit()
        renew_question.close()
    def reduce_higher_mathematics_grade(self):
        import mysql.connector
        global questions_grade
        global questions_name

        questions_grade = str(questions_grade).replace('[', '').replace(']', '').replace("'", "")
        questions_grade=int(questions_grade)
        print(questions_grade)
        print(questions_name)
        questions_grade = questions_grade - 1
        questions_grade=str(questions_grade)
        questions_name = str(questions_name)
        if questions_grade==0:
            renew_question = mysql.connector.connect(
                host="localhost",
                user="root",
                passwd="dxy123",
                db='study'
            )
            mycursor = renew_question.cursor()
            mysql = "delete from Gaoshu where question number=%s"
            mycursor.execute(mysql,(questions_name,))
            renew_question.commit()
            renew_question.close()
        else:
            renew_question = mysql.connector.connect(
                host="localhost",
                user="root",
                passwd="dxy123",
                db='study'
            )
            mycursor = renew_question.cursor()
            mysql = 'update high number set tag=%s where question number=%s'
            mycursor.execute(mysql,(questions_grade,questions_name,))
            renew_question.commit()
            renew_question.close()
    def review_higher_mathematics_page(self):
        import mysql.connector
        import random
        global easy_question_list
        global difficult_question_list
        global problem_question_list
        global max_global
        global first_global
        global second_global
        import numpy as np
        global random_easy_number1
        global random_easy_number2
        global random_difficult_number1
        global random_problem_number1

        self.review_page.destroy()
        self.page2 = Frame(self.root)
        self.page2.pack()
        Label(self.page2, text='Du Xiaoyang's postgraduate entrance examination wrong question book').grid(row=0, stick=W, pady=30)
        select_question = mysql.connector.connect(
            host="localhost",
            user="root",
            passwd="dxy123",
            db='study'
        )
        mycursor1 = select_question.cursor()
        mysql1= 'SELECT * FROM high number WHERE tag <= 2'
        mycursor1.execute(mysql1)
        # Get the query results and assign them to variables
        easy_question_list = mycursor1.fetchall()
        for i in easy_question_list:
            print(i)
        # Close cursor and connection
        mycursor1.close()
        matrix1= np.array(easy_question_list)
        easy_question_list_rows,easy_question_list_cols=matrix1.shape
        print(easy_question_list_rows)
        print(easy_question_list_cols)
        mycursor2 = select_question.cursor()
        mysql1 = 'SELECT * FROM high number WHERE tag > 2 and tag <= 4'
        mycursor2.execute(mysql1)
        # Get the query results and assign them to variables
        difficult_question_list = mycursor2.fetchall()
        for j in difficult_question_list:
            print(j)
        # Close cursor and connection
        mycursor2.close()
        matrix2 = np.array(difficult_question_list)
        difficult_question_list_rows, difficult_question_list_cols = matrix2.shape
        mycursor3 = select_question.cursor()
        mysql1 = 'SELECT * FROM high number WHERE tag > 4 '
        mycursor3.execute(mysql1)
        # Get the query results and assign them to variables
        problem_question_list = mycursor3.fetchall()
        for k in problem_question_list:
            print(k)
        # Close cursor and connection
        mycursor3.close()
        matrix3 = np.array(problem_question_list)
        problem_question_list_rows, problem_question_list_cols = matrix3.shape
        select_question.close()
        #选题
        first_num = 1
        random_easy_number1 = random.randint(first_num,easy_question_list_rows)
        random_easy_number2 = random.randint(first_num, easy_question_list_rows)
        while random_easy_number1 == random_easy_number2:
            random_easy_number2 = random.randint(first_num, easy_question_list_rows)
        random_difficult_number1 = random.randint(first_num, difficult_question_list_rows)
        random_problem_number1 = random.randint(first_num, problem_question_list_rows)
        Button(self.page2, text='Ask a question', command=self.set_question).grid(row=1, pady=5)
        Button(self.page2, text='1',command=self.question1).grid(row=2, pady=5)
        Button(self.page2, text='2',command=self.question2).grid(row=3, pady=5)
        Button(self.page2, text='3',command=self.question3).grid(row=4, pady=5)
        Button(self.page2, text='4',command=self.question4).grid(row=5, pady=5)
        Button(self.page2, text='answer',command=self.show_answer).grid(row=6, pady=5)
        Button(self.page2, text='right',command=self.reduce_higher_mathematics_grade).grid(row=7, pady=5)
        Button(self.page2, text='wrong',command=self.add_higher_mathematics_grade).grid(row=8, pady=5)

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Python entry skill treeBasic skillsDatabase operation 381643 people are learning the system