添加知识点对应的题目的算法

Posted chaosliang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了添加知识点对应的题目的算法相关的知识,希望对你有一定的参考价值。

import pandas as pd

def input_prob(grade, subject, knowledge, type_p, prob, A, B, C, D, res):
    grade = int(grade)
    if grade <= 6:
        stemp1 = "小学\\"
    elif grade <= 9:
        stemp1 = "初中\\"
    else:
        stemp1 = "高中\\"
    stemp2 = "C:\\Users\\lenovo\\Desktop\\数据库\\"
    pos = stemp2 + stemp1 + subject + ".xlsx"
    df1 = pd.read_excel(pos, sheet_name="repository", dtype="涉及题目": str)
    df1.set_index("ID")
    df2 = pd.read_excel(pos, sheet_name="problems")
    df2.set_index("ID")
    index = df2.index[-1] + 1
    flag = False
    for i in df1.index:
        if df1.at[i, "知识点"] == knowledge:
            flag = True
            temp = i
            if df1["涉及题目"].at[i] == "nan":
                df1["涉及题目"].at[i] = str(index)
            else:
                df1["涉及题目"].at[i] += " "
                df1["涉及题目"].at[i] += str(index)
            break
    if not flag:
        return [False, "未找到相应知识点"]
    df2.loc[index] = [index, type_p, prob, A, B, C, D, res, temp, ""]
    writer = pd.ExcelWriter(pos)
    df1.to_excel(writer, sheet_name="repository")
    df2.to_excel(writer, sheet_name="problems")
    writer.save()
    return [True, "导入成功"]

input_prob("6", "数学", "数与代数", "选择题", "证明费马大定理", 0, 1, 2, 3, "A")

 

以上是关于添加知识点对应的题目的算法的主要内容,如果未能解决你的问题,请参考以下文章

每周学算法/读英文/知识点心得分享 3.4 - 3.8

:高频算法第27节:高频面试算法 - 基础(下)

算法题目--知识盲区记录一下

面试篇——机器学习综合面试题

PASCAL算法知识题~~高分~紧急~

每周学算法/读英文/知识点心得分享 2.4 - 2.8