Untitled
unknown
python
8 months ago
654 B
6
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("------------------")
passEditor is loading...
Leave a Comment