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.
# 1
def create_dictionary(keys, values):
pass
# 2
def value_count(values):
pass
# 3
def double_values(dict1):
pass
if __name__=="__main__":
keyList =[]
# Read from file and store the data in keyList
# If you can't get the files working, fill keyList manually
#TODO
print("The list of keys is:")
print(keyList)
valueList =[]
# Read from file and store the data in valueList
# If you can't get the files working, fill valueList manually
#TODO
print("The list of values is:")
print(valueList)
print("The complete dictionary is:")
dict1={} #TODO change this to call create_dictionary instead
print(dict1)
print("Each value occurs the following number of times:")
dict2={} #TODO change this to call value_count instead
print(dict2)
print("The double value dictionary is:")
dict3={} #TODO change this to call double_values instead
print(dict3)
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:
1.(6 points) create_dictionary: 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.
2.(6 points) value_count: 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.
3.(5 points) double_values: 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 __name__=="__main__":) 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. (4 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. (4 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!