Question: Using Python, write a program that takes input keywords from a list to create a dictionary which consists of all the keywords as keys and

Using Python, write a program that takes input keywords from a list to create a dictionary which consists of all the keywords as keys and their count of occurrence as values.
a) Define a main function and write all the logic inside this function. Do not forget the function call for the main function at the end of the program. [10% marks]
b) Create a list named keywordsList which consists of 20 python keywords. The list must contain duplicate values as well. Some examples of python keywords are: and, del, global, while, for, in, else, print, return, import, if, elif, break, continue, etc. [20% marks]
c) Create an empty dictionary named dictionary. The keywords from the list defined above will represent the keys and their respective count of occurrence will represent the values for the dictionary. [10% marks]
d) Iterate through the list and increment the value of the current keyword for the dictionary. [25% marks]
e) Sort the dictionary based on the count of occurrence of the keyword in descending order. (Hint: use python's sorted() in-built function to sort the dictionary)[25% marks]
f) The expected output is given below: (Hint: use ljust() function to adjust the spacing for the output)[10% marks]. Keyword_name is the name of the keyword selected from the list into the dictionary which acts as the key. count is the number of occurrences of the keyword in the list which acts as the value in the dictionary.
\table[[Keyword_name,Count],[print,5],[and,4],[break,4],[del,3],[else,3],[while,3],[return,2],[import,2],[in,2],[continue,2],[not,1],[def,1],[elif,1],[global,1],[or,1],[if,1],[for,1]]
 Using Python, write a program that takes input keywords from a

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!