Commit b630cf17 by BellCodeEditor

save project

parent 3f0f3d56
Showing with 8 additions and 14 deletions
# 期末考试结束了,悟空在教务系统查到了自己的几门必修课分数,他想通过python计算自己的平均分。 goods = {'可口可乐':3,'旺仔牛奶':4,'农夫山泉':1,'辣条':3,'巴西烤肉':2,'果冻':4,'乐事':5,'奥利奥':10,'巧克力':6}
# 于是写了下面的代码,可是总是得不到结果,请帮纠正bug并跑通程序。 goods.pop('农夫山泉')
print(goods)
scores = {'语文':89, '数学':95, '英语':80} goods.clear()
def get_average(scores): print(goods)
sum_score = 0 del(goods)
for subject, score in scores.items(): print(goods)
sum_score += score \ No newline at end of file
print('现在的总分是%d'%sum_score)
ave_score = sum_score/len(scores)
print('平均分是%d'%ave_score)
get_average(scores)
\ No newline at end of file
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