# The aim of this module is to assign a rating to # each of the 'genres' in the dataset. # The idea here is to create a dictionary with # the name of the genres as keys and the average revenue # generated by the movies in that genre as values assigned to these keys. import creatingDictionary dataset = creatingDictionary.test() def populate(): ''' The output of this function is a dictionary which has as keys the names of genres that appear in the dataset. The values assigned to the keys are all zero. ''' genreDictionary = {} for film in dataset: if not (film['Genre'] in genreDictionary): genreDictionary[film['Genre']] = 0 return genreDictionary def assignCount(): ''' The output of this function is the dictionary in which the keys - the names of the genres and the value - number of occurrences in the dataset. ie the number of films in the dataset falls under the genre. ''' genresDictionary = populate() count = 0
# The aim of this module is to assign a rating to # each of the 'genres' in the dataset. # The idea here is to create a dictionary with # the name of the genres as keys and the average revenue # generated by the movies in that genre as values assigned to these keys. import creatingDictionary dataset=creatingDictionary.test() def populate(): ''' The output of this function is a dictionary which has as keys the names of genres that appear in the dataset. The values assigned to the keys are all zero. ''' genreDictionary={} for film in dataset: if not(film['Genre'] in genreDictionary): genreDictionary[film['Genre']]=0 return genreDictionary def assignCount(): ''' The output of this function is the dictionary in which the keys - the names of the genres and the value - number of occurrences in the dataset. ie the number of films in the dataset falls under the genre. ''' genresDictionary=populate() count=0 for film in dataset: if (film['Genre'] in genresDictionary): genresDictionary[film['Genre']]+=1