Question: Complete the python program ( lab9.py ) that contains a main() function as well as a recurse() function. The program should take a folder listed
Complete the python program (lab9.py) that contains a main() function as well as a recurse() function. The program should take a folder listed below and print the total number of functions in ALL the python files in that folder and all its subfolders.
folder: https://www.dropbox.com/sh/jkayk68a5718fqs/AAAojisDWtEp7K5nQN_eHPR0a?dl=0
Complete the recurse() function such that:
The recurse() function must be a recursive function that takes in a path to a folder and recursively traverses the folder looking for python files.
You can use the isfile(path) function to check if a path is a file or a directory.
The base case is when path contains a single file. If the file is a python file, then open the file and count the number of functions that are in that file. Increment the global counter variable for the total number of functions seen so far. Do not forget to close the file.
The recursion is for the case when a folder contains another subfolder. You then need to go through all the files/folders in that subfolder and keep recursively calling recurse(). You can use the listdir() function for this part of the lab.
You need one for loop in the recursive condition.

Testing your program To run the program, you must use command line parameters. Command line parameters are values that you can pass into your program from the command line. You must run the program as follows to get the following output: python3 lab9.py assignments/ Name of the program: lab9.py First parameter passed to the program through the command line: assignments/ The number of functions in all the python files is nesods in ail the pythoo In addition to starter code, we have also provided a folder (called assignments) with subfolders and some python files for testing your program. For the provided folder, the number of functions contained by all the Python files in all the folders and their respective subfolders is 21. You can also test your program on a smaller subset of folders/files on your own computer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
