#Homework 2-5

#Complete the parts marked as TODO. Other parts of the program are provided
#as examples and test cases.

#Examples with dictionaries (pay attentions to the use of [] and {}):

inventory = {} # an empty dictionary
inventory = {'orange':5, 'apple':3, 'banana':5, 'mango':4}
inventory['peach'] = 10 # add key with value to a dictionary
inventory['banana'] = 9 # update values in a dictionary
numOfBananas = inventory['banana'] # query a dictionary

for k in inventory.keys(): # iterate through dictionary keys
        print(k)
        print(inventory[k])
        


#Your name here:

#Here is dictionary of movies with their box offices
#The keys are movie titles and the values are domestic revenues, adjusted for inflation

#This dictionary is made so that you have some data to test your functions.
#Again, your functions should perform correctly on ANY input.
domesticGrosses = {'Snow White and the Seven Dwarfs':868730000, 
                     'Avatar':775124500, 
                     'Return of the Jedi':749653500, 
                     'Jurassic Park':687060600, 
                     'Gone with the Wind':1610295700, 
                     'The Graduate':682004000, 
                     'The Empire Strikes Back':782499700, 
                     'Star Wars':1419613200, 
                     'The Sound of Music':1135050500, 
                     'Pirates of the Caribbean: Dead Man\'s Chest':515088100, 
                     'The Lion King':615537400, 
                     'The Godfather':629012900, 
                     'Forrest Gump':626008500, 
                     'The Lord of the Rings: The Return of the King':490459000, 
                     'My Fair Lady':478200000, 
                     'Harry Potter and the Sorcerer\'s Stone':445626500, 
                     'Spider-Man':553793400, 
                     'The Dark Knight':592028200, 
                     'Titanic':1022916700, 
                     'E.T.':1130579000}


def printMovieNames(dict):
	''' Given a dictionary of movies and revenues, print out all the movie names '''
	keys = dict.keys()
	for k in keys:
		print(k)
	return

#TODO: Write a function that prints out the revenues instead
def printMovieRevenues(dict):
	''' Given a dictionary of movies and revenues, print out all the movie revenues '''
	#TODO: fill in the function body
	return
	

def startsWithTHE(dict):
	''' Given a dictionary of movies and revenues, return a dictionary of all the movies
		whose titles start with the word 'The' '''
	result = {}
	for k in dict.keys():
		if k[0:3] == 'The':
			result[k] = dict[k]
	
	return result

#TODO: Write a function that takes a movie-revenue dictionary as input, and returns 
# a dictionary of all the movies that grossed over $1,000,000,000 
def hugeMovies(dict):
	''' Given a dictionary of movies and revenues, return a dictionary of all the movies
		that grossed over one billion dollars '''
	#TODO: fill in the function body
	return dict	# not the correct answer
	
#TODO: Write a function that takes a movie-revenue dictionary as input , and returns
# the title of the movie that had the highest revenue
# It's a quite complicated function, so here are some steps to guide you:
# (or you can ignore it if you have a good idea)
# 1. Create two variables called biggestMovieSoFar and biggestRevenueSoFar (What their values should be?)
# 2. Iterate through all movies in your input, and for each one, do the following
#		a. Compare its revenue to biggestRevenueSoFar
#		b. If its revenue is bigger, update biggestRevenueSoFar to be this bigger revenue, and update biggestMovieSoFar to be its title
#		c. Otherwise do nothing
# 3. At the end, your biggestMovieSoFar should hold the name of the highest grossing movie. Convince yourself why.
def biggestMovie(dict):
	''' Given a dictionary of movies and revenues, return the title of the highest grossing movie. '''
	#TODO: fill in the function body
	return 'Avatar' # not the correct answer... is it?














