有人能告訴我我的代碼有什麼問題嗎?我必須創建成績簿應用程序
- 在控制檯上顯示所有學生及其成績。你的清單應該包括一個指定類名,章節和分級權重的標題。
- 計算所有學生的成績,並在控制檯上顯示這些信息以及學生的字母等級(請注意,學生成績是加權的!)。
- 計算平均成績爲班級和字母等級爲類
代碼:
f=open("greades.txt", "r")
sum=0
for line in f:
#split data into rows
items = line.split()
sum=0
#getting the data in rows
for i in range(1,9):
sum+=int(items[i])
print(items[0],"\tTotal:",sum,"\tAverage:",sum/9)
def average(mygreades):
""" Function to calculate the average of an input of the List that i have """
if(len(mygreades)==0):
return 0.0
mygreades=[1]
sum=0
for item in mygreades:
sum+=item
avg = sum/len(mygreades)
return avg
def converter(mygreades):
""" Function will convert an input list of strings to a number list """
numberList = []
for item in mygreades:
if(item.isnumeric()):
numberList.append(eval(item))
return numberList
main()
你遇到了什麼問題?爲什麼這個標籤C? – JJJ
你會得到什麼,爲什麼它是錯的 – octoback
它不在IDEL運行 – user2351884