Hi everyone,
I finally found the time to finish the dictionary section. The final step was the filtering for the intervals.
I just want to run my code by you and compare it to the sample answer was given.
Mine:
rating_count =
for c_rating in apps_data[1:]:
rating = float(c_rating[5])
rating_count.append(rating)min_rating = min(rating_count)
max_rating = max(rating_count)print(min_rating)
print(max_rating)
Answer:
rating_counts =
for c_ratings in apps_data[1:]:
rating_counts.append(int(c_ratings[5]))ratings_max = max(rating_counts)
ratings_min = min(rating_counts)print(ratings_max)
print(ratings_min)
Now both gave the same result for the min/max rating. My only question is what you would do differently?
also here’s my code for the filtering intervals:
ratings_frequency = {‘0 - 10000’: 0, ‘10000 - 100000’: 0, ‘100000 - 500000’: 0, ‘500000 - 1000000’: 0, ‘1000000+’: 0}
for rows in apps_data[1:]:
ratings = float(rows[5])if ratings <= 10000: ratings_frequency['0 - 10000'] += 1 elif 10000 < ratings <= 100000: ratings_frequency['100000 - 500000'] += 1 elif 100000 < ratings <= 500000: ratings_frequency['100000 - 500000'] += 1 elif 500000 < ratings <= 1000000: ratings_frequency['500000 - 1000000'] += 1 elif ratings > 1000000: ratings_frequency['1000000+'] += 1
print(ratings_frequency)
my answer is : {‘1000000+’: 6, ‘500000 - 1000000’: 16, ‘0 - 10000’: 6181, ‘100000 - 500000’: 994, ‘10000 - 100000’: 0}
while the sample answer is: {‘1000000+’: 6, ‘500000 - 1000000’: 16, ‘0 - 10000’: 6181, ‘100000 - 500000’: 196, ‘10000 - 100000’: 798}
I cannot for the life of me see where I made a mistake.