#Function and loops, and returning several values #write a program that reads number of students #in the class, grade for each student, #and finds the number of students who passed #and the average passing grade #USE FUNCTIONS! #we will write a function pass_grade #that has one parameter - numbers of students in #the class #function reads a grade for each student #and returns: number of students who passed #and average passing grade #write a program that randomly generates #the numbers of students in the class and test the #function. Randomly generate the grades #Assume that range will be VALID #number of students >0 #grade 0 to 100 #we will limit number of student to 10 import random LOW_GRADE=0 UPPER_GRADE=100 LOW=5 UPPER=10 def pass_grade(num_stud): counter=1 counterPass=0 sumPass=0 while(counter<=num_stud): grade=random.randint(LOW_GRADE,UPPER_GRADE) print(grade) if(grade>=60): counterPass=counterPass+1 sumPass=sumPass+grade counter=counter+1 if(counterPass>0): ave=sumPass/counterPass else: ave=0.0 return counterPass, ave def main(): num_stud=random.randint(LOW, UPPER) print(num_stud) cPass, avePass= pass_grade(num_stud) if(cPass>0): print(cPass, "students passed the class") print("passing grade is", avePass) else: print("NOBODY PASSED") main()