exDotaPro

7_april_2019_5_movie_ratings

Jan 21st, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. movies_to_watch = int(input())
  2.  
  3. total_rating = 0
  4. top_rated_movie = 0
  5. lowest_rated_movie = 11
  6. top_rated_movie_name = ''
  7. lowest_rated_movie_name = ''
  8.  
  9. for movies in range(movies_to_watch):
  10.     movie_name = input()
  11.     movie_rating = float(input())
  12.     total_rating += movie_rating
  13.  
  14.     if movie_rating > top_rated_movie:
  15.         top_rated_movie = movie_rating
  16.         top_rated_movie_name = movie_name
  17.  
  18.     if movie_rating < lowest_rated_movie:
  19.         lowest_rated_movie = movie_rating
  20.         lowest_rated_movie_name = movie_name
  21.  
  22. print(f'{top_rated_movie_name} is with highest rating: {top_rated_movie:.1f}')
  23. print(f'{lowest_rated_movie_name} is with lowest rating: {lowest_rated_movie:.1f}')
  24. print(f'Average rating: {total_rating / movies_to_watch:.1f}')
Add Comment
Please, Sign In to add comment