Python Forum
How to write a dict code in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to write a dict code in python
#1
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!
buran write Oct-31-2023, 08:35 AM:
Please, post your python code in the post, using BBcode tags (python tag in particular). Don't attach py file

Attached Files

.py   py4202.py (Size: 2.65 KB / Downloads: 61)
Reply
#2
Do you have a question? What have you tried so far? This is not a forum that does your homework for you.
ariellea88 likes this post
Reply
#3
(Oct-30-2023, 12:17 PM)deanhystad Wrote: Do you have a question? What have you tried so far? This is not a forum that does your homework for you.

Hello! Thank you for your reply!

Yes! The question is how do you use different fonts in your code?
This one is the one I am stuck with.

Thanky you!
Reply
#4
(Oct-31-2023, 07:45 AM)ariellea88 Wrote: Yes! The question is how do you use different fonts in your code?
If you want to know how to post code in the forum, this is explained in the BBcode help page.
Reply
#5
It looks, the attached file py4202.py are some helper functions you are supposed to use in your code. Please, post what have YOU tried to complete the assignment. We are glad to help, but we are not here to do your homework for you.
Please, post your code (in code tags) and ask specific questions. Don't forget to include the full traceback (in error tags) if you get one.
Check Homework and No Effort Questions
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to write code demon_calcifer 1 1,626 Nov-16-2021, 04:09 PM
Last Post: Larz60+
  Can someone please help me write the code Ram 8 3,350 Feb-08-2021, 08:21 AM
Last Post: Serafim
  Please help me to write code for this vij 8 3,795 Jun-10-2020, 12:13 PM
Last Post: pyzyx3qwerty
  Python Adding +1 to a list item cointained in a dict ElReyZero 1 2,081 Apr-30-2020, 05:12 AM
Last Post: deanhystad
  Write pseudo code for a class assignment Scrimshot 3 3,402 May-07-2019, 05:38 PM
Last Post: Scrimshot
  Write a code to output in alphabetical order AbdelaliPython 1 4,627 Jan-19-2018, 09:03 PM
Last Post: j.crater
  how to write a code for term that can't begin or end with a stopword desul 3 3,793 Mar-18-2017, 03:42 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020