我知道在我的循环中输入了一个预告片值来结束程序。我的程序的目的是输入孩子的名字,然后输入他们的成绩。当您完成一个孩子时,您输入 -1 以结束该部分程序。在你完成一个孩子之后,程序应该要求你输入另一个孩子的名字。预告片值“完成”有效,但是当我输入一个随机孩子的名字时,它会说这个名字没有定义,它不会运行程序的其余部分。帮助?
#By: Christian Braverman 01/02/13
#Variables
TotalNum_A = 0
TotalNum_B = 0
TotalNum_C = 0
TotalNum_D = 0
TotalNum_F = 0
studentname = 0
Done = 0
grade = 0
#Loop
studentname = input("Enter student name ")
while studentname != Done :
studentname = input ("Enter student name ")
grade = input("Enter a Grade ")
while grade != -1:
grade = input("Enter a Grade: ")
if grade >=90 :
print "A!"
TotalNum_A = TotalNum_A + 1
if grade >=80 and grade <90:
print "B!"
TotalNum_B = TotalNum_B + 1
if grade >=70 and grade <80:
print "C"
TotalNum_C = TotalNum_C + 1
if grade >=60 and grade <70:
print "D"
TotalNum_D = TotalNum_D + 1
if grade <=59:
print "F :("
TotalNum_F = TotalNum_F + 1
grade = input("Enter a Grade: ")
#Printing Totals
print ("You received " + str(TotalNum_A) + " A's.")
print ("You recieved " + str(TotalNum_B) + " B's.")
print ("You recieved " + str(TotalNum_C) + " C's.")
print ("You recieved " + str(TotalNum_D) + " D's.")
print ("You recieved " + str(TotalNum_F) + " F's.")