Question

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...

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
    """

Solutions

Expert Solution

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)


Related Solutions

In python def lambda_2(filename): # Complete this function to read grades from `filename` and map the...
In python def lambda_2(filename): # Complete this function to read grades from `filename` and map the test average to letter # grades using map and lambda. File has student_name, test1_score, test2_score, # test3_score, test4_score, test5_score. This function must use a lambda # function and map() function. # The input to the map function should be # a list of lines. Ex. ['student1,73,74,75,76,75', ...]. Output is a list of strings in the format # studentname: Letter Grade -- 'student1: C' #...
In Python: def _nodeAtIndex(self, index): """Returns the reference to the node at the given index; If...
In Python: def _nodeAtIndex(self, index): """Returns the reference to the node at the given index; If index is out of range, raise IndexError """ # PROBLEM 2 # You can assume that index is non-negative. # You need to traverse the list and stop at the required index. # YOUR CODE HERE (THIS IS WHAT I HAVE CURRENTLY WRITTEN BUT I"M STUCK AND DON"T KNOW WHAT TO DO) while current != None: # use a while-loop. plist.append(current._element) # process the...
IN PYTHON Given a string with duplicate characters in it. Write a program to generate a...
IN PYTHON Given a string with duplicate characters in it. Write a program to generate a list that only contains the duplicate characters. In other words, your new list should contain the characters which appear more than once. Suggested Approach Used two nested for loops. The first for loop iterates from 0 to range(len(input_str)). The second for loop iterates from first_loop_index + 1 to range(len(input_str)). The reason you want to start at first_loop_index + 1 in the nested inner loop...
A student majoring in economics is looking for a job. Given his work experience and grades,...
A student majoring in economics is looking for a job. Given his work experience and grades, the probability of getting a job offer from a firm to which he applies is 50%. If he applies to 3 firms, what is the probability that he gets 2 job offers? (Find the nearest answer.) a. 24.3% b. 38.4% c. 43.2% d. 37.5% e. 44.1%
python coding Suppose a list of positive numbers is given like the following list (remember this...
python coding Suppose a list of positive numbers is given like the following list (remember this is only an example and the list could be any list of positive numbers) exampleList: 15 19 10 11 8 7 3 3 1 We would like to know the “prime visibility” of each index of the list. The “prime visibility” of a given index shows how many numbers in the list with indexes lower than the given index are prime. For instance, in...
This is Python coding question, and topic is loop Can anyone help me figuring these out?...
This is Python coding question, and topic is loop Can anyone help me figuring these out? (Please do not use build in function) Thanks. 1. Write a program that prints your name 100 times to the screen. 2. Write a program that takes a string s and an integer n as parameters and prints the string s a total of in n times(once per line) 3. Write a for loop that prints all the integers from 3141 to 5926, skipping...
Using python coding, test for convergence of an infinite sequence or series. keep the coding at...
Using python coding, test for convergence of an infinite sequence or series. keep the coding at beginner level please!
How would I setup this dictionary for Python 3? class Student(object): def __init__(self, id, firstName, lastName,...
How would I setup this dictionary for Python 3? class Student(object): def __init__(self, id, firstName, lastName, courses = None): The “id”, “firstName” and “lastName” parameters are to be directly assigned to member variables (ie: self.id = id) The “courses” parameter is handled differently. If it is None, assign dict() to self.courses, otherwise assign courses directly to the member variable. Note: The “courses” dictionary contains key/value pairs where the key is a string that is the course number (like “course1”) and...
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal...
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal to n, such that the digit to the right is greater than the left digit (ai+1 > ai). E.g. if n=3 (123,124,125,……129,234,…..789)
I have a python coding question: Write the function: eAapproximately (n), that takes a positive integer...
I have a python coding question: Write the function: eAapproximately (n), that takes a positive integer value n and returns an approximation of e as (1 + 1/n)^n I am not even sure what the question is asking me to do but I think it is asking me to code that function. Does anyone know how to do this?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT