Oct-30-2023, 07:12 AM
Hello dear All!
I am a newcomer, could you please explain what is required to do first here?
1. Write a function process(text). This function should return a dictionary where:
a) The keys of the dictionary are the names of colleges.
b) The values of the dictionary are the number of students admitted to each college.
c) The parameter text comes from the text file mingdan.txt. Be sure to specify the correct file encoding when calling the read_text function.
2. Write a function sort_dict(adict, reverse). This function should return a list where:
a) Each element in the list is a tuple in the form (key, value).
b) The parameter adict is of type dictionary. The parameter reverse controls whether to sort by the reverse order of values.
Requirements:
a) Use functions from the py4202.py file, such as read_text and output.
b) Place the complete code in master.py. Place the relevant test code in master_test.py, where some code has already been written. Please complete it.
c) The code uses third-party libraries matplotlib and wordcloud. Please use the following commands to install the third-party libraries:
pip install matplotlib
pip install wordcloud
If using macOS, replace "pip" with "pip3" in the above commands.
\\
Thank you!
I am a newcomer, could you please explain what is required to do first here?
1. Write a function process(text). This function should return a dictionary where:
a) The keys of the dictionary are the names of colleges.
b) The values of the dictionary are the number of students admitted to each college.
c) The parameter text comes from the text file mingdan.txt. Be sure to specify the correct file encoding when calling the read_text function.
2. Write a function sort_dict(adict, reverse). This function should return a list where:
a) Each element in the list is a tuple in the form (key, value).
b) The parameter adict is of type dictionary. The parameter reverse controls whether to sort by the reverse order of values.
Requirements:
a) Use functions from the py4202.py file, such as read_text and output.
b) Place the complete code in master.py. Place the relevant test code in master_test.py, where some code has already been written. Please complete it.
c) The code uses third-party libraries matplotlib and wordcloud. Please use the following commands to install the third-party libraries:
pip install matplotlib
pip install wordcloud
If using macOS, replace "pip" with "pip3" in the above commands.
\\
Thank you!