def get_average_rating(ratings):
 rating_weightings = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5}
 if ratings:
  rating_sum = 0.0
  number_of_ratings = get_number_of_ratings(ratings)
  if (number_of_ratings == 0):
   return 0
  for (rating_value, rating_count) in ratings.items():
   rating_sum += (rating_weightings[rating_value] * rating_count)
  return (rating_sum / (number_of_ratings * 1.0))

def get_average_rating ( ratings ) : rating_weightings = { '1' : 1 , '2' : 2 , '3' : 3 , '4' : 4 , '5' : 5 } if ratings : rating_sum = 0.0 number_of_ratings = get_number_of_ratings ( ratings ) if ( number_of_ratings == 0 ) : return 0 for ( rating_value , rating_count ) in ratings . items ( ) : rating_sum += ( rating_weightings [ rating_value ] * rating_count ) return ( rating_sum / ( number_of_ratings * 1.0 ) )
returns the average rating of the ratings as a float .