Using Python, write a program that takes input keywords from a list to create a dictionary...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
python def main keywordslist print and break del else while for in return import if elif break conti... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Create a conclusion to following work. Hotels form an uninterrupted narrative of a story, filling guests with emotions that define their stay. They have ceased to be considered one-dimensional places...
-
93) Clay of the Land is a manufacturer of glazed clay pots. Currently, it produces 300 clay pots per month which it sells through nurseries at a constant price of $5 per pot. Current demand for clay...
-
The Energy Guide label on a washing machine indicates that the washer will use $85 worth of hot water per year if the water is heated by an electric water heater at an electricity rate of $0.082/kWh....
-
In the design of all-terrain vehicles, it is necessary to consider the failure of the vehicle when attempting to negotiate two types of obstacles. One type of failure is called hang-up failure and...
-
Consider the following cash flow profile and assume MARR is 10 percent/year and the finance rate is 4 percent/year. a. Determine the MIRR for this project. b. Is this project economically attractive?...
-
During its first year of operations, Gavin Company had credit sales of $3,000,000; $600,000 remained uncollected at year-end. The credit manager estimates that $31,000 of these receivables will...
-
A tiling company has been tasked to tile the floor of a new shopping mall using the following materials and creating the design which follows: . Square marble slabs . Heavy duty rods on the outer...
-
Brothers Herm and Steve Hargenrater began operations of their tool and die shop (H & H Tool) on January 1, 1987, in Meadville, PA. The annual reporting period ends December 31. Assume that the trial...
-
1. A company is known to cut costs by not being environmentally friendly. However, it provides the cheapest version of the product you need. What do you do? 2. Discuss the advantages and...
-
Explain the differences between a company issuing a bond versus taking a loan from a bank. How are they similar, and how are they different?
-
Think of three people from your own life (or even from popular TV shows and films) who are or were unemployed, employed, and not in the labor force. What events and choices led to their employment...
-
When the Federal Deposit Insurance Corporation (FDIC) created deposit insurance after the Great Depression, what effect did this have on the occurrence of bank runs? Did the introduction of deposit...
-
Explain how the Federal Reserve plays a central role in determining the slope of the aggregate demand curve. For example, if a lower price level leads inflation to be below the Feds target rate, how...
-
Do changes in stock prices precede economic downturns and expansions, or do they follow changes in economic activity? Are stock market prices a cause or an effect of changes in the macroeconomy?
-
A corporate bond is currently trading at a price that is below its par value. Which of the following statements is the BEST explanation of why this is happening? O A. This bond has become relatively...
-
Identify the source of funds within Micro Credit? How does this differ from traditional sources of financing? What internal and external governance mechanisms are in place in Micro Credit?
-
True or False: SESAME is an authentication system that is the result of a European research and development project and is similar to Kerberos.
-
Review how once an IDPS detects an anomalous network situation, it has several options, depending on the policy and objectives of the organization that has configured it as well as the capabilities...
-
Conclude that the most critical component of an IR plan is to stop the incident and contain the scope and/or impact to the organization. With time being of the essence, detailed analyses here are not...
-
Explain the effect of each of these on the shape and position of the countrys production-possibility curve: a. A proportionate increase in the total supplies (endowments) of all factors of...
-
Why does the HeckscherOhlin theory predict that most research and development (R&D) activity is done in the industrialized countries?
-
A free-trade equilibrium exists in which the United States exports machinery and imports clothing from the rest of the world. The goods are produced with two factors: capital and labor. The trade...
Study smarter with the SolutionInn App