Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. Counting Keywords Write a Python program that will read any Python source program file and print out a frequency count of the reserved words

image text in transcribed

A. Counting Keywords Write a Python program that will read any Python source program file and print out a frequency count of the reserved words in the file. You can find a list of the Python keywords on the Python.org website: docs.python.org/3/reference/1exical-analysis.html#keywords Your program should print each keyword and its associated count, one per line, in alphabetic order. Do not list keywords that appear zero times in the file. Do not import or use any Python modules in your program. Your program should do the following: 'Prompt the user and input the name of a Python source code file (.py) * Read the contents of the file and construct a dictionary consisting of the keywords and their associated counts *Print a list of all keywords and their associated counts in alphabetic order of keywords (include only those with non-zero counts) Example: Enter the filename: junk2.py Keyword frequency in alphabetic order: def for if in return 3 6 A. Counting Keywords Write a Python program that will read any Python source program file and print out a frequency count of the reserved words in the file. You can find a list of the Python keywords on the Python.org website: docs.python.org/3/reference/1exical-analysis.html#keywords Your program should print each keyword and its associated count, one per line, in alphabetic order. Do not list keywords that appear zero times in the file. Do not import or use any Python modules in your program. Your program should do the following: 'Prompt the user and input the name of a Python source code file (.py) * Read the contents of the file and construct a dictionary consisting of the keywords and their associated counts *Print a list of all keywords and their associated counts in alphabetic order of keywords (include only those with non-zero counts) Example: Enter the filename: junk2.py Keyword frequency in alphabetic order: def for if in return 3 6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

What standard ratios are applicable to all companies? AppendixLO1

Answered: 1 week ago