Question: Write the following functions specified in the code and instructions below. As you write the functions, test them and compare your output with example run.
Write the following functions specified in the code and instructions below. As you write the functions, test them and compare your output with example run.
#
def createdictionarykeys values:
pass
#
def valuecountvalues:
pass
#
def doublevaluesdict:
pass
if namemain:
keyList
# Read from file and store the data in keyList
# If you can't get the files working, fill keyList manually
#TODO
printThe list of keys is:
printkeyList
valueList
# Read from file and store the data in valueList
# If you can't get the files working, fill valueList manually
#TODO
printThe list of values is:
printvalueList
printThe complete dictionary is:
dict #TODO change this to call createdictionary instead
printdict
printEach value occurs the following number of times:"
dict #TODO change this to call valuecount instead
printdict
printThe double value dictionary is:
dict #TODO change this to call doublevalues instead
printdict
Make sure that the program that you upload runs. If you have trouble with any function, comment the function call in the main.
If you cannot manage to read the files, fill in the lists manually.
Here are more specific directions about each function and the main statement:
points createdictionary: This function accepts two lists as parameters, a list of keys, and a list of values. It then creates and returns a dictionary created with the parameters.
points valuecount: This function accepts a list as a parameter, a returns a dictionary with each unique element from the list as keys, and values of the total occurrences of that element in the parameter list.
points doublevalues: This function accepts a dictionary as a parameter, and returns a copy of the dictionary with doubled values.
The main part of the program if namemain: should do the following in addition to what has been provided:
a Read in the data from the file games.txt and use it to fill the list keyList. Each line should be a new element in the list. points
b Read in the data from the file publishers.txt and use it to fill the list valueList. Each line should be a new element in the list. points
c Fix the function calls for each of the functions specified above included in the function points
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
