Sichanov

exam preparation 2

Apr 17th, 2021
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. failed_grades = int(input())
  2.  
  3. failed_times = 0
  4. number_solved_problems = 0
  5. grade_sum = 0
  6. last_problem = ''
  7. has_failed = False
  8. command = input()
  9. while not command == 'Enough':
  10.     problem_name = command
  11.     grade = int(input())
  12.     number_solved_problems += 1
  13.     if grade <= 4:
  14.         failed_times += 1
  15.         if failed_times == failed_grades:
  16.             has_failed = True
  17.             break
  18.     grade_sum += grade
  19.     last_problem = problem_name
  20.     command = input()
  21. if has_failed:
  22.     print(f"You need a break, {failed_grades} poor grades.")
  23. else:
  24.     print(f"Average score: {grade_sum / number_solved_problems:.2f}")
  25.     print(f"Number of problems: {number_solved_problems}")
  26.     print(f"Last problem: {last_problem}")
Advertisement
Add Comment
Please, Sign In to add comment