From ff921240cfa7f31340897cc0853f30428a923d4a Mon Sep 17 00:00:00 2001
From: BellCodeEditor <bellcode_dev@bell.ai>
Date: Thu, 26 Sep 2024 20:26:54 +0800
Subject: [PATCH] auto save

---
 bj.py   |  3 +++
 diy1.py | 18 +++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)
 create mode 100644 bj.py

diff --git a/bj.py b/bj.py
new file mode 100644
index 0000000..1d7057d
--- /dev/null
+++ b/bj.py
@@ -0,0 +1,3 @@
+for k in dict.keys():# 遍历字典里的键
+for v in dict.values():# 遍历字典里的值
+for k,v in dict.items():# 遍历字典里的键和值
\ No newline at end of file
diff --git a/diy1.py b/diy1.py
index eefeb2c..d7a2818 100644
--- a/diy1.py
+++ b/diy1.py
@@ -1,16 +1,16 @@
 # 期末考试结束了,悟空在教务系统查到了自己的几门必修课分数,他想通过python计算自己的平均分。
 # 于是写了下面的代码,可是总是得不到结果,请帮纠正bug并跑通程序。
+# python笔记本
+scores = {'语文':89, '数学':95, '英语':80} # 字典
 
-scores = {'语文':89, '数学':95, '英语':80}
+def get_average(dict_1):
+    sum = 0 # 用来表示总分
 
-def get_average(dict_1)):
-    score = 0
-
-    for subject, score in scores.items():
-
-        score += score
-        print('现在的总分是%d'%score)
-    ave_score = score/len(scores)
+    for subject, score in scores.items(): # 遍历字典里的键和值
+    
+        sum=sum+score
+        print('现在的总分是%d'%sum)
+    ave_score = sum/len(scores)
     print('平均分是%d'%ave_score)
 
 get_average(scores)
\ No newline at end of file
--
libgit2 0.25.0