Created
October 14, 2019 10:32
-
-
Save okellogabrielinnocent/6876c31ac52375f74697936eaea26068 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Transform the frequencies inside content_ratings to proportions and percentages while creating separate dictionaries for each. | |
# Assign the dictionary storing proportions to a variable named c_ratings_proportions. | |
# Assign the dictionary storing percentages to a variable named c_ratings_percentages. | |
# Optional challenge: try to solve this exercise using a single for loop (solution to this challenge provided). | |
content_ratings= {'4+': 4433, '12+': 1155, '9+': 987, '17+': 622} | |
total_number_of_apps = 7197 | |
c_ratings_proportions = {} | |
c_ratings_percentages = {} | |
for key in content_ratings: | |
proportion = content_ratings[key] / total_number_of_apps | |
c_ratings_proportions[key] = proportion | |
for key in c_ratings_proportions: | |
percentage = c_ratings_proportions[key] * 100 | |
c_ratings_percentages[key] = percentage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment