This Python program reads the GPA of 15 students.
It calculates and displays the average of all GPAs that are greater than 15.
total = 0
count = 0
for i in range(1, 16):
grade = float(input(f"Enter GPA for student {i}: "))
if grade > 15:
total += grade
count += 1
if count == 0:
print("No GPA above 15 was entered.")
else:
average = total / count
print(f"Average GPA above 15: {average:.2f}")
Enter GPA for student 1: 14.2
Enter GPA for student 2: 16.5
...
Enter GPA for student 15: 15.8
Average GPA above 15: 16.15
- The program loops 15 times to read each student's GPA
- If a GPA is greater than 15, it adds it to the total and increments the count
- After the loop, it calculates the average using total / count
- If no GPA is above 15, it displays a message accordingly