# # Author: James Tam # Version: October 26, 2011 (Python 3 port) # # The first version of a program that tracks the grades for a class. # (This version employs an inappropriate implementation and is used only # for illustration purposes only - what could be done with an array/list). # Global constant CLASS_SIZE = 5 # Get class data stu1 = float(input("Enter grade for student no. 1: ")) stu2 = float(input("Enter grade for student no. 2: ")) stu3 = float(input("Enter grade for student no. 3: ")) stu4 = float(input("Enter grade for student no. 4: ")) stu5 = float(input("Enter grade for student no. 5: ")) #Calculate pertinent statistics total = stu1 + stu2 + stu3 + stu4 + stu5 average = total / CLASS_SIZE # Display results print() print("GRADES") print("The average grade is %.2f%%" %average) print("Student no. 1: %.2f" %stu1) print("Student no. 2: %.2f" %stu2) print("Student no. 3: %.2f" %stu3) print("Student no. 4: %.2f" %stu4) print("Student no. 5: %.2f" %stu5)