Advertisement
veronikaaa86

02. Exam Preparation

Jul 30th, 2023
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. number_poor_grades = int(input())
  2.  
  3. flag = False
  4. count_poor = 0
  5. sum_grades = 0
  6. count_grades = 0
  7. last_problem = ""
  8. input_line = input()
  9. while input_line != "Enough":
  10.     current_grade = int(input())
  11.     if current_grade <= 4:
  12.         count_poor += 1
  13.  
  14.     if count_poor == number_poor_grades:
  15.         flag = True
  16.         break
  17.  
  18.     count_grades = count_grades + 1
  19.     sum_grades = sum_grades + current_grade
  20.     last_problem = input_line
  21.  
  22.     input_line = input()
  23.  
  24. if flag:
  25.     print(f"You need a break, {count_poor} poor grades.")
  26. else:
  27.     avg_grade = sum_grades / count_grades
  28.     print(f"Average score: {avg_grade:.2f}")
  29.     print(f"Number of problems: {count_grades}")
  30.     print(f"Last problem: {last_problem}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement