编写一个代码,计算一个学生的一组成绩和 return 该学生的字母成绩
Write a code that will average a set of grades for a student and return the letter grade for that student
程序会询问要平均的成绩分数,然后循环接受给定的成绩分数。输入所有分数后,程序将通过将所有分数相加并除以输入的分数数来平均分数(注意:您需要在循环输入分数时将分数相加。)一旦平均计算后,程序将根据以下内容查看应将哪个字母等级分配给平均值
下面提供的比例。
谁能帮我用累加器创建一个循环?这是我到目前为止所做的:
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
现在你知道了一步一步的操作方法,你要做的就是将它转换成代码
程序会询问要平均的成绩分数,然后循环接受给定的成绩分数。输入所有分数后,程序将通过将所有分数相加并除以输入的分数数来平均分数(注意:您需要在循环输入分数时将分数相加。)一旦平均计算后,程序将根据以下内容查看应将哪个字母等级分配给平均值 下面提供的比例。
谁能帮我用累加器创建一个循环?这是我到目前为止所做的:
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
现在你知道了一步一步的操作方法,你要做的就是将它转换成代码