The assignement:

Make a program that returns as output "Congratulations # for the excellent performance!" to all students (replacing the name "#" with the student's name) who have an average grade (of all their subjects) higher than the class average.

- It is necessary to ask the names of the students, the names of the subjects, the grades of the students in each of the subjects and the average of each student.

- Students must be displayed on the monitor, sorted by their average. The name and average of each student should appear. Must use the bubble sort function.

- Must display the name of the student (and respective average) of the student with the best average on the monitor.

- Must display the name of the student (and respective average) of the student with the lowest average on the monitor.

Note: The names of the subjects must be asked only once by the program- the subjects must be associated to each student.

--------

Hello, this is my assignement, I've been trying to make it in different ways for a couple of days and this has been my most sucessful try. As you can see, I've written that the class has 3 students but in reality it should have 30 (I did this for it to be quicker).

The program that I made is also very long and is quite different from what my professor wants. We just finished learning about append, functions and lsits.

If someone could show me how it's done, I'd appreciate it alot!

(Sorry if my english is bad.)

**What I have tried:**
num_students = 3
num_subjects = 5
sum_class = 0
sum_student = 0
averages_students = [[]]
names = []
subjects = []
average_class = 0
name_disc_grades = [[]]
i = 0
j = 0
grade = 0
while i < num_subjects:
name_subject = input("Name of the subject: ")
if name_subject:
subjects.append(name_subject)
i = i + 1
name_subject = None
print("List of subjects: ")
print(subjects)
i = 0
while i < num_students:
name_student = input("Name of the student: ")
if name_student:
name_student = input("Name of the student: ")
if name_student
subjects.append(name_student)
i = i + 1
name_student = None
i = 0
j = 0
name_disc_grades.clear()
averages_students.clear()
for i in range(num_students):
while j < num_subjects:
grade = eval(input("indicate the grade of student " + names[i] + " the subject " + subjects[j] + ": "))
names_disc_grades.append([str(names[i]), str(subjects[j]), float(grade)])
if grade:
sum_class = sum_class + int(grade)
sum_student = sum_student+ int(grade)
j = j + 1
print("----------------------------------------------------------------------")
averages_students.append([str(names[i]), float(sum_student / num_subjects)])
sum_student = 0
j = 0
i = i + 1
average_class = float(sum_class/num_subjects/num_students)
print("")
print("average of class is: ", average_class)
print("")
print("all averages of students: ")
print(averages_students)
def bubbleSort(theSeq):
n = len(theSeq)
for i in range(n - 1):
flag = 0
for j in range(n-1):
if theSeq[j][1] > theSeq[j + 1]
[1]:
tmp = theSeq[j]
theSeq[j] = theSeq[j + 1]
theSeq[j + 1] = tmp
flag = 1
if flag == 0:
breakpoint()
return theSeq
average_students = bubbleSort(averages_students)
print("")
print('averages sorted: ')
print(average_students)
print("")
print("the student with the biggest/better average and:", averages_students[-1][0])
print(congratualations for the excelent performance!")
print("with the average of: ", averages_students[-1][-1])
# here the same, and always the first score of the list [name, average]
# the student with smallest average
print("")
print("students with average superior to the average of the class are: ")
i=0
#compare
for i in range(num_students):
if average_students[i][1] > average_class:
print('Congratulations'. names[i], "for your average of", average_students[i][1], "!")
print("----------------")
#extra - show all grades by student by subject.
print("")
print("All of the grades of each student by subject: ", names_disc_grades)