From 501114e44845f2d665646dbda737cf9807879492 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Fri, 14 Mar 2025 16:27:19 +0800 Subject: [PATCH] save project --- diy1.py | 10 +++++----- 新建文本文档.txt | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 新建文本文档.txt diff --git a/diy1.py b/diy1.py index eefeb2c..5fe7b45 100644 --- a/diy1.py +++ b/diy1.py @@ -3,14 +3,14 @@ scores = {'语文':89, '数学':95, '英语':80} -def get_average(dict_1)): - score = 0 +def get_average(dict_1): + total = 0 - for subject, score in scores.items(): + for subject, score in dict_1.items(): - score += score + total += score print('现在的总分是%d'%score) - ave_score = score/len(scores) + ave_score = total/len(scores) print('平均分是%d'%ave_score) get_average(scores) \ No newline at end of file diff --git "a/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" "b/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" new file mode 100644 index 0000000..3eb61cd --- /dev/null +++ "b/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" @@ -0,0 +1,16 @@ +# 期末考试结束了,悟空在教务系统查到了自己的几门必修课分数,他想通过python计算自己的平均分。 +# 于是写了下面的代码,可是总是得不到结果,请帮纠正bug并跑通程序。 + +scores = {'语文':89, '数学':95, '英语':80} + +def get_average(dict_1)): + score = 0 + + for subject, score in scores.items(): + + score += score + print('现在的总分是%d'%score) + ave_score = score/len(scores) + print('平均分是%d'%ave_score) + +get_average(scores) \ No newline at end of file -- libgit2 0.25.0