Advertisement
differen71

movie_ratings

Jul 16th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. chosen_movies_qty = int(input())
  2. highest_rating = 0
  3. lowest_rating = 0
  4. total_movies_rating = 0
  5. highest_rating_movie = ''
  6. lowest_rating_movie = ''
  7. for movie in range(chosen_movies_qty):
  8.     current_movie = input()
  9.     rating = float(input())
  10.     total_movies_rating += rating
  11.     if rating > highest_rating:
  12.         highest_rating = rating
  13.         lowest_rating = rating
  14.         highest_rating_movie = current_movie
  15.     elif rating < lowest_rating:
  16.         lowest_rating = rating
  17.         lowest_rating_movie = current_movie
  18. average_movies_rating = total_movies_rating / chosen_movies_qty
  19. print(f"{highest_rating_movie} is with highest rating: {highest_rating:.1f}")
  20. print(f"{lowest_rating_movie} is with lowest rating: {lowest_rating:.1f}")
  21. print(f"Average rating: {average_movies_rating:.1f}")
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement