Commit cba7563e by BellCodeEditor

save project

parent 3771f013
Showing with 10 additions and 17 deletions
# 期末考试结束了,悟空在教务系统查到了自己的几门必修课分数,他想通过python计算自己的平均分。 # 期末考试结束了,悟空在教务系统查到了自己的几门必修课分数,他想通过python计算自己的平均分。
# 于是写了下面的代码,可是总是得不到结果,请帮纠正bug并跑通程序。 # 于是写了下面的代码,可是总是得不到结果,请帮纠正bug并跑通程序。
s = {'语文':1, '数学':1,} scores = {'语文':89, '数字':95, '英语':80}
def get_average(s):
a = 0
for subject, a in s.items():
a += a
print('现在的总分是%d'%a)
ave_a = a/len(s)
print('平均分是%d'%ave_a)
def get_average(scores):
sum_score = 0
for subject,score in scores.items():
sum_score += score
print('现在的总分是%d'%sum_score)
ave_score = sum_score/len(scores)
print('平均分是%d'%ave_score)
l = {'t':s , '英语':1} get_average(scores)
def get_average(l): \ No newline at end of file
for subject, t in l.items():
t += t
print('现在的总分是%t'%a)
ave_a = a/len(l)
print('平均分是%d'%ave_a)
get_average(l)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment