Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3 (10 points): Purpose: To generalize an existing function so that it can perform a wider range of subtasks. Degree of Difficulty: Moderate Function

image text in transcribed

Question 3 (10 points): Purpose: To generalize an existing function so that it can perform a wider range of subtasks. Degree of Difficulty: Moderate Function print_disk_quota displays the amount of space in gigabytes (GB) and percentage of space that specific file types occupy on a hard drive: def print_disk_quota () : Displays (to console) the amount of space in GB and percentage of space that major file types occupy on the hard drive as well as the amount of space free/available for use. # calculate percentage of space occupied by certain file types capacity = 1024.0 media_percent = 365.0/1024.0 * 100.0 # capacity of hard drive in GB # percentage of hard drive occupied # by multimedia files documents_percent = 10.0/1024.0 * 100.0 # percentage of hard drive occupied # by document files # percentage of hard drive occupied # by applications # percentage of hard drive available applications_percent = 425.00/1024.0 * 100.0 free percent = 224.0/1024.0 * 100.0 # print disk quota to console print("You have "+str(free_percent) + " % of "+str (capacity)+" GB free.") print (str(media_percent)+ "% of hard drive space (365.0 GB)"+ is occupied by multimedia files.") print (str(documents_percent)+"% of hard drive space (10.0 GB)"+ " is occupied by document files.") print(str(applications_percent)+"% of hard drive space (425.0 GB)"+ " is occupied by applications.") Recall that the generalization of a function is the process of revising a function to solve a wider range of problems. Generalize this function by converting appropriate literal values in the function into parameters so that it can print the disk quota usage for different hard drive capacities and different amounts of space used by each file type. You may have to modify multiple lines of the function body to accommodate for a new parameter value. Also modify the docstring to describe the new parameters. The above function is already provided for you in a2q3-starter.py, so you don't have to re-write it. You should test that the function produces the same output for every parameter introduced. That is, if you give the function the same specific inputs used in the starter code as arguments for your new parameters, you should wind up with the same output in both scenarios. What to Hand In Hand in your solution in a file called a2q3.py. Evaluation 2 marks for generalizing the hard drive capacity as a parameter. 6 marks for generalizing each of the three file types' space usage as a parameter (2 marks per file type parameter). 2 marks for appropriate modifications to the docstring -1 mark if identifying information (name, NSID, student number and instructor's name) is missing

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

Step: 3

blur-text-image

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions