Part of the series

Several example codes

~2 min read • Updated Oct 7, 2025

Program Overview

This Python program reads the number of students n.
Then it reads n GPA values and identifies the highest conditional GPA (i.e., GPA less than 12).
The variable grade stores each GPA, and max_conditional stores the highest one among the conditional cases.


Python Code:


n = int(input("Enter number of students: "))
max_conditional = -1  # Initial value for highest conditional GPA

for i in range(n):
    grade = float(input(f"Enter GPA for student {i + 1}: "))
    if grade < 12:
        if grade > max_conditional:
            max_conditional = grade

if max_conditional == -1:
    print("There are no conditional students.")
else:
    print(f"Highest conditional GPA: {max_conditional:.2f}")

Sample Output:


Enter number of students: 5  
Enter GPA for student 1: 14.5  
Enter GPA for student 2: 11.8  
Enter GPA for student 3: 9.7  
Enter GPA for student 4: 12.0  
Enter GPA for student 5: 10.2  

Highest conditional GPA: 11.80

Step-by-Step Explanation:

- The program first reads the number of students
- Then it loops through each student and reads their GPA
- If the GPA is below 12, it is considered conditional
- The program tracks the highest conditional GPA and displays it at the end


Written & researched by Dr. Shahin Siami