Advertisement
mark79

Graduation pt.2

Feb 17th, 2020
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. student = input()
  2.  
  3. student_class = 1
  4. total_grade = 0
  5. bad_grade = 0
  6.  
  7. while student_class <= 12 and bad_grade != 2:
  8.     current_grade = float(input())
  9.     if current_grade >= 4:
  10.         total_grade += current_grade
  11.         student_class += 1
  12.     else:
  13.         bad_grade += 1
  14.  
  15. if bad_grade == 2:
  16.     print(f"{student} has been excluded at {student_class} grade")
  17. else:
  18.     avg_grade = total_grade / 12
  19.     print(f"{student} graduated. Average grade: {avg_grade:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement