程序将要求平均分数,然后循环接受给定的分数。输入所有分数后,程序将通过将所有等级分数相加并除以输入的分数来平均等级(注意:您需要在循环输入时将等级相加。)一旦计算出平均值,程序将根据以下提供的比例查看应将哪个字母等级分配给平均值。
有人可以帮我用累加器创建一个循环吗?
Num = int(input("Enter the number of scores: "))
score = int(input("Enter a score: "))
Average = (score/Num)
if (Average >= 93):
print("A")
elif(Average >= 85):
print("B")
elif(Average >= 77):
print("C")
elif(Average >= 69):
print("D")
elif(Average <= 68):
print("F")
我假设你根据你给出的语法在 python 中编写代码。你可以尝试在实际实现它之前首先为它制作一个伪代码。
declaring totalScore = 0
declaring average = 0
declaring score
# input number of lesson will be counted to enter the score
input numOfLesson
# Looping to enter the score of each student to list
for i in range(numOfLesson):
input score
total = total + score
# you got the total score, and what you have to do is to divide it with numOfLesson
# to get the average
average = total / numOfLesson
现在你知道一步一步如何做到这一点,你要做的是将其转换为代码
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(4条)