Question: 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

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
Get step-by-step solutions from verified subject matter experts
