BbJLeB

02. Exam Preparation

May 14th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #02. Exam Preparation
  2.  
  3. max_bad_grades = int(input())
  4.  
  5. bad_grades_count = 0
  6. total = 0
  7. problems_count = 0
  8. last_problem = None
  9.  
  10. while bad_grades_count < max_bad_grades:
  11.     problem = input()
  12.     if problem == "Enough":
  13.         break
  14.     grade = int(input())
  15.     if grade <= 4:
  16.         bad_grades_count +=1
  17.  
  18.     total += grade
  19.     problems_count += 1
  20.     last_problem = problem
  21.  
  22. if bad_grades_count == max_bad_grades:
  23.     print(f"You need a break, {bad_grades_count} poor grades.")
  24. else:
  25.     average = total / problems_count
  26.     print(f"Average score: {average:.2f}")
  27.     print(f"Number of problems: {problems_count}")
  28.     print(f"Last problem: {last_problem}")
Advertisement
Add Comment
Please, Sign In to add comment