python用户输入若干个分数_编写一个程序,要求用户输入五个测试分数。与字母grad对应...

Determine_grade-接受单个数字作为参数,并根据以下评分标准显示分数的字母等级:Score 90-100 80-89 70-79 60-69 Below 60

Letter Grade A

B

C

D

Fcalc_average-以分数列表作为参数,显示分数的平均值,以及与该平均值相等的字母分数。

main-要求用户输入五个测试分数,并将它们作为数字放入列表中

showLetters–echo打印用户输入的分数和字母等级相等

按每个主要步骤写评论。下面是程序的运行示例:

输入等级:65、80、90、71、8565.0 is D

80.0 is B

90.0 is A

71.0 is C

85.0 is B

平均值是:78.2,也就是Cdef main():

enter code herescores = input("Enter five test scores seperated by commas:")

listScores = scores.split(",")`enter code here`

determine_grade(listScores)

calc_average(listScores)

def determine_grade(grades):

for num in grades:

if int(num) >= 90 and int(num) <= 100:

print("A")

elif int(num) >=80 and int(num) <= 89:

print("B")

elif int(num) >=70 and int(num) <= 79:

print("C")

elif int(num) >=60 and int(num) <= 69:

print("D")

else:

print("F")

def calc_average(grades):

total = 0

for num in grades:

total += int(num)

average = total / 5

print(average)

#def show_letters(values):

main()

这就是我目前所拥有的,但似乎还不知道如何格式化它?

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值