Advertisement
veronikaaa86

02. Exam Preparation

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