Advertisement
Merucial

Exam Preparation

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