Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Using Python, write a program that takes input keywords from a list to create a dictionary which consists of 

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 keywords List 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. Keyword_name Count print and 5 break del else while return import in continue not def elif 1443332222222 global 1 or if for

Step by Step Solution

3.47 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

Heres the Python program def main Create a list of Python keywords keywordslist and as assert async ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Information Security

Authors: Michael E. Whitman, Herbert J. Mattord

7th Edition

035750643X, 978-0357506431

More Books

Students also viewed these Programming questions

Question

describe the distinct effects of positive emotions;

Answered: 1 week ago