#write a program that first randomly generates the number of students in the #class. The class size will be between 15 and 24 #Then for each student the program randomly generates final grade. The #program finds the number of students who failed the class (grade below 60) #the number of students who got A (grade 95 - 100) #and their averages import random size_class=random.randint(15,24) print("size of the class is",size_class) cF=0 cA=0 totalF=0 totalA=0 for i in range(size_class): #grade=random.randint(0,100) #grade=random.randint(60,100) # this will check special case nobody failed grade=random.randint(0,94) #this will check special case nobody got A print(grade) if(grade<60): cF=cF+1 totalF=totalF+grade elif(grade>=95): cA=cA+1 totalA=totalA+grade if(cF>0): print(cF, "failed") print("failing average is",totalF/cF) else: print("nobody failed") if(cA>0): print(cA,"got A") print("their average",totalA/cA) else: print("nobody got A") #Testing the program #the random data that was generated was: size of the class 18 #and grades: 96 18 15 2 69 77 22 13 48 51 93 90 88 5 94 32 39 98 #the A grades are: 96 and 98 and their average (96+98)/2=97.0 and that matches the #output #Failing grades are: 18 15 2 22 13 48 51 5 32 39 #there are 10 failing grades #average (18+ 15+ 2+ 22+ 13+ 48+ 51+ 5+ 32+ 39)/10= 24.5 #it matches the out my program printed #based on this the program runs correctly #if we want to check special cases: nobody failed, nobody got A #in order to do that we make change in the range of the grade