教師が学生ID番号と生徒の成績を入力できるクラスの課題を終了します。最終学年は計算され、学生番号の隣に返されます。私は最終的なグレードを計算することはできますが、グレードを学生のリストに追加することはできません。初心者のpythonユーザーが関数間でデータをやりとりする必要があります
def assignments():
assign1 = int(input("Assignment 1 grade: "))
if assign1 > 100:
print ("Please input a valid grade value.")
assign1 = int(input("Assignment 1 grade: "))
assign2 = int(input("Assignment 2 grade: "))
if assign2 > 100:
print ("Please input a valid grade value.")
assign2 = int(input("Assignment 2 grade: "))
assign3 = int(input("Assignment 3 grade: "))
if assign3 > 100:
print ("Please input a valid grade value.")
assign3 = int(input("Assignment 3 grade: "))
assign4 = int(input("Assignment 4 grade: "))
if assign4 > 100:
print ("Please input a valid grade value.")
assign4 = int(input("Assignment 4 grade: "))
assign5 = int(input("Assignment 5 grade: "))
if assign5 > 100:
print ("Please input a valid grade value.")
assign5 = int(input("Assignment 5 grade: "))
assign6 = int(input("Assignment 6 grade: "))
if assign6 > 100:
print ("Please input a valid grade value.")
assign6 = int(input("Assignment 6 grade: "))
assign7 = int(input("Assignment 7 grade: "))
if assign7 > 100:
print ("Please input a valid grade value.")
assign7 = int(input("Assignment 7 grade: "))
assign8 = int(input("Assignment 8 grade: "))
if assign8 > 100:
print ("Please input a valid grade value.")
assign8 = int(input("Assignment 8 grade: "))
assign9 = int(input("Assignment 9 grade: "))
if assign9 > 100:
print ("Please input a valid grade value.")
assign9 = int(input("Assignment 9 grade: "))
assign10 = int(input("Assignment 10 grade: "))
if assign10 > 100:
print ("Please input a valid grade value.")
assign10 = int(input("Assignment 10 grade: "))
assignGrade = assign1 + assign2 + assign3 + assign4 + assign5 + assign6 + assign7 + assign8 + assign9 + assign10
aGrade = assignGrade/10
print("The final grade for all assignments is: ")
print(aGrade)
midterm = int(input("Midterm grade: "))
if midterm > 100:
print ("Please input a valid grade value.")
midterm = int(input("Midterm grade: "))
finalExam = int(input("Final Exam grade: "))
if finalExam > 100:
print ("Please input a valid grade value.")
finalExam = int(input("Final Exam grade: "))
testsGrade = midterm + finalExam
tGrade = testsGrade/2
print("The final grade for all test is: ")
print(tGrade)
participation = int(input("Participation grade: "))
if participation > 100:
print ("Please input a valid grade value.")
participation = int(input("Participation grade: "))
partGrade = participation
print("The final grade for Participation is: ")
print(partGrade)
finalGrade = aGrade + tGrade + partGrade/3
def students():
netIDList = []
maxLengthList = 6
while len(netIDList) < maxLengthList:
ID = input("Enter Student's Net ID: ")
netIDList.append(ID)
for s in netIDList:
print("Please input grades for student " + s)
assignments()
f = assignments().finalGrade
netIDList.append(": " + f)
print(netIDList)
def main():
students()
main()
バック値を返します:あなたはすべての生徒の名前をそうような彼らのスコアとを印刷することができます
この道を – Li357
のIDが間違っていますので、作業中のプログラムがあるように修正してください。 – Vorsprung
IDLE環境でインデントが正しいので、その部分を無視してください。 –