Question: PLEASE SOLVE BY PYTHON Write a program that reads in a Python source code file and counts the occurrence of each identifier (variables, class, and

PLEASE SOLVE BY PYTHON

PLEASE SOLVE BY PYTHON Write a program that reads in a Python

Write a program that reads in a Python source code file and counts the occurrence of each identifier (variables, class, and method names) in the file using a dictionary. Another dictionary is used to positions of identifiers with a list in the file. Your program should prompt the user to enter the Python source code filename and then construct these two dictionaries. After reading the entire file, the program should display the contents two dictionaries. Ex: ab = de x = x + ab + 1 y=ab #starts at 0 #starts at 8 #starts at 22 dictCounts: {'ab': 3, 'de': 1, 'x': 3, 'y': 1} dictPositions: {'ab': [0, 16, 26], 'de': [5], 'x': [8, 12), 'y': [22]}

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!