..

Applying Knowledge - Class 5

Create a Python program that requests the number of students in a specific class.

After receiving this information, the user should enter the average grade for each student. The program will then display the message CONGRATULATIONS YOU HAVE BEEN APPROVED for students with an average grade of 6.0 or higher.

Additionally, the program should calculate and display the overall class average after all the data has been input.

Note: If the number of students in the class is zero, the program should display the following message: THERE WAS NO PROCESSING.

Input:

  1. The number of students in a specific class.
  2. The average grade for each student (one by one).

Output:

  • For each student whose average grade is 6.0 or higher, display the message CONGRATULATIONS YOU HAVE BEEN APPROVED at the end.

Sample Inputs/Outputs:

foo@bar:~$ py baz.py
0
THERE WAS NO PROCESSING
foo@bar:~$
foo@bar:~$ py baz.py
3
10.0
CONGRATULATIONS YOU HAVE BEEN APPROVED
8.5
CONGRATULATIONS YOU HAVE BEEN APPROVED
5.5
8.0
foo@bar:~$

SOLUTION:

total_students = int(input())
if total_students < 1:
    print('NÃO HOUVE PROCESSAMENTO')
else:
    count = 0
    total_avg_grade = 0
    while count < total_students:
        avg_grade_sdt = float(input())
        if avg_grade_sdt > 5.9:
            print('PARABÉNS VOCÊ ESTÁ APROVADO')
        total_avg_grade += avg_grade_sdt
        count += 1
    print(total_avg_grade/total_students)