Untitled
unknown
python
11 days ago
654 B
5
Indexable
def calc_avg(matches, user, film): # Avg Calc try: ratings = [int(i)/2 for i in matches if 1 <= int(i) <= 10] avg_rating = sum(ratings) / len(ratings) stdv = statistics.stdev(ratings) fans_or_haters = "Fans" if avg_rating < 3: fans_or_haters = "Haters" # Prints print(f"{user}\n{film}\navg : {round(avg_rating, 2)}\nstd dev : {round(stdv, 2)}\n{len(ratings)}" f" {fans_or_haters} have rated") print("--------------------------") except: print(f"{user} needs more cultured fans") print("------------------") pass
Editor is loading...
Leave a Comment