|
40 | 40 | },
|
41 | 41 | {
|
42 | 42 | "cell_type": "code",
|
43 |
| - "execution_count": 2, |
| 43 | + "execution_count": 11, |
44 | 44 | "metadata": {},
|
45 | 45 | "outputs": [],
|
46 | 46 | "source": [
|
47 |
| - "midterm_exam_df = pd.read_excel(\"AI100 인공지능개론 중간고사 채점 (파이썬).xlsx\", engine='openpyxl')\n", |
48 |
| - "final_exam_df = pd.read_excel(\"AI100 인공지능개론 기말고사 채점 (파이썬).xlsx\", engine='openpyxl')" |
| 47 | + "midterm_exam_df = pd.read_excel(\"강의 1 중간고사 채점 (파이썬).xlsx\", engine='openpyxl')\n", |
| 48 | + "final_exam_df = pd.read_excel(\"강의 1 기말고사 채점 (파이썬).xlsx\", engine='openpyxl')\n", |
| 49 | + "total_exam_df = pd.read_excel(\"강의 1 총점 (파이썬).xlsx\", engine='openpyxl')" |
49 | 50 | ]
|
50 | 51 | },
|
51 | 52 | {
|
52 | 53 | "cell_type": "code",
|
53 |
| - "execution_count": 14, |
| 54 | + "execution_count": 23, |
| 55 | + "metadata": {}, |
| 56 | + "outputs": [], |
| 57 | + "source": [ |
| 58 | + "def total_score_txt(exam_score_dataframe_midterm, exam_score_dataframe_final, exam_score_dataframe_total, txt_file_path):\n", |
| 59 | + " student_num = len(exam_score_dataframe_midterm)\n", |
| 60 | + " \n", |
| 61 | + " with open(txt_file_path, \"w\") as f:\n", |
| 62 | + " for i in range(student_num):\n", |
| 63 | + " student_info_midterm = list(exam_score_dataframe_midterm.loc[i, :])\n", |
| 64 | + " student_info_final = list(exam_score_dataframe_final.loc[i, :])\n", |
| 65 | + " student_info_total = list(exam_score_dataframe_total.loc[i, :])\n", |
| 66 | + " student_infos = [student_info_midterm, student_info_final, student_info_total]\n", |
| 67 | + " for num, student_info in enumerate(student_infos):\n", |
| 68 | + " if num == 0: columns = list(exam_score_dataframe_midterm.columns) \n", |
| 69 | + " elif num == 1: columns = list(exam_score_dataframe_final.columns)\n", |
| 70 | + " elif num == 2: columns = list(exam_score_dataframe_total.columns)\n", |
| 71 | + " \n", |
| 72 | + " for idx, (j, k) in enumerate(zip(columns, student_info)):\n", |
| 73 | + " if num == 0 and idx == 1: f.write('중간고사:\\n') \n", |
| 74 | + " elif num == 1 and idx == 2: f.write('기말고사:\\n') \n", |
| 75 | + " elif num == 2 and idx == 2: f.write('총점:\\n') \n", |
| 76 | + "\n", |
| 77 | + " if num == 2 and idx == 6: \n", |
| 78 | + " f.write('{}: {} (10점 만점) \\n'.format(j, k))\n", |
| 79 | + " else:\n", |
| 80 | + " f.write('{}: {}\\n'.format(j, k)) \n", |
| 81 | + " f.write('\\n')\n", |
| 82 | + " f.close()" |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + "cell_type": "code", |
| 87 | + "execution_count": 7, |
54 | 88 | "metadata": {},
|
55 | 89 | "outputs": [],
|
56 | 90 | "source": [
|
|
71 | 105 | },
|
72 | 106 | {
|
73 | 107 | "cell_type": "code",
|
74 |
| - "execution_count": 16, |
| 108 | + "execution_count": 4, |
| 109 | + "metadata": {}, |
| 110 | + "outputs": [], |
| 111 | + "source": [ |
| 112 | + "score_txt(midterm_exam_df, \"강의 1 중간고사 채점 (파이썬).txt\")\n", |
| 113 | + "score_txt(final_exam_df, \"강의 1 기말고사 채점 (파이썬).txt\")" |
| 114 | + ] |
| 115 | + }, |
| 116 | + { |
| 117 | + "cell_type": "code", |
| 118 | + "execution_count": 24, |
75 | 119 | "metadata": {},
|
76 | 120 | "outputs": [],
|
77 | 121 | "source": [
|
78 |
| - "score_txt(midterm_exam_df, \"AI100 인공지능개론 중간고사 채점 (파이썬).txt\")\n", |
79 |
| - "score_txt(final_exam_df, \"AI100 인공지능개론 기말고사 채점 (파이썬).txt\")" |
| 122 | + "total_score_txt(midterm_exam_df, final_exam_df, total_exam_df, \"강의 1 총점 (파이썬).txt\")" |
80 | 123 | ]
|
81 | 124 | }
|
82 | 125 | ],
|
83 | 126 | "metadata": {
|
84 | 127 | "kernelspec": {
|
85 | 128 | "display_name": "exercise",
|
86 | 129 | "language": "python",
|
87 |
| - "name": "python3" |
| 130 | + "name": "exercise" |
88 | 131 | },
|
89 | 132 | "language_info": {
|
90 | 133 | "codemirror_mode": {
|
|
0 commit comments