def get_counts_and_averages(ID_and_ratings_tuple):
    """Given a tuple (bookID, ratings_iterable) 
    returns (bookID, (ratings_count, ratings_avg))
    """
    nratings = len(ID_and_ratings_tuple[1])
    return ID_and_ratings_tuple[0], (nratings, float(sum(x for x in ID_and_ratings_tuple[1]))/nratings)