Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a script that prompts for the user to input a directory and then prints o

ID: 3646352 • Letter: C

Question

Create a script that prompts for the user to input a directory and then prints out the number of subdirectories in the given directory, as well as the number of files (use the numbers only for the directory given, you do NOT need to do this recursively for all subdirectories). Output should look like:



$ssenesy_prob2



Please enter a directory: /usr/bin



Directory: /usr/bin

Files: 45 Sub-directories: 8



Do you wish to continue (y/n): n

$



The script should execute until an exit condition is met, clearing the screen of the previous information before prompting for new input.

Explanation / Answer

Python Code import os import bin dir = input("Please specify the location to the directory") list = os.walk(dir) a = length(list[1]) b = length(list[2]) print "Files: %n , Sub-dirs : %n" % (b,a) decision = _(" Do you want to continue? (y/n) ")) if(decision): cls else : exit()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote