In: Computer Science
Coding in python question
def generate_project_data_files(expected_grade_file_path,
std_dev, num_projects, folder_path):
"""
For given student expected grades, generate the grades as
described in generate_assignment_data given std_dev.
For this method, you will generate multiple files for each project.
For example, if num_projects = 4, then you should generate four files
according to the following naming convention:
"P_0.csv" ... "P_3.csv" . The files should be written in the folder
defined by folder_path.
For example, given num_projects = 1 and folder_path="data", you should
create one file of test grades in "data/P_0.csv"
You should be making use of the generate_assignment_data method above!
:param expected_grade_file_path: This is our file of student IDs and expected grades
:param std_dev: Standard deviation used when sampling grades
:param num_projects: Number of project files to generate
:param folder_path: location of the output files.
:return: Total number of grade samples written to all project files
"""
The required code & output is given below:
(Please note that the contents of the output files will depend on the generate assignment data function that is used in it. I have implemented the requirements of the function asked in this question):
CODE:
def generate_project_data_files(expected_grade_file_path,std_dev, num_projects, folder_path):
out_files_list = []
total_samples = 0 #initialize total samples to 0
for i in range(num_projects):
out_files_list.append(f"P_{i}.csv")
if not os.path.exists(folder_path): os.mkdir(folder_path) # make directory
out_file_path = folder_path + os.sep + f"P_{i}.csv" #generate file path for output by adding
#call generate assignment data function with the generated out file path
total_samples += generate_assignment_data(expected_grade_file_path,std_dev,out_file_path)[0]
return total_samples
CODE SCREENSHOT (For indentation reference):

OUTPUT:
Files in the required output folder specified:

(*Note: Please up-vote. If any doubt, please let me know in the comments)