Advertisement
PowerCell46

Graduation Python

Dec 17th, 2022
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. student_name = input()
  2. reached_grade = 1
  3. sum_grades = 0
  4. excluded = 0
  5.  
  6. while reached_grade <= 12:
  7.     current_grade = float(input())
  8.     if current_grade < 4:
  9.         excluded += 1
  10.         if excluded > 1:
  11.             break
  12.         continue
  13.     sum_grades += current_grade
  14.     reached_grade += 1
  15.  
  16. average_grade = sum_grades /12
  17.  
  18. if excluded >= 2:
  19.     print(f'{student_name} has been excluded at {reached_grade} grade')
  20. else:
  21.     print(f'{student_name} graduated. Average grade: {average_grade:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement