Question
Could someone pls help me with these two functions in python? Function name: find_avg Parameters: file_name (str), student_name (str) Return value: student_avg (float) Description: Read
Could someone pls help me with these two functions in python?
Function name: find_avg
Parameters: file_name (str), student_name (str)
Return value: student_avg (float)
Description: Read in a file (that has the same format shown above). Find the student specified by the
parameter. Generate the average of all the students score and return the average. If the student has
a DNT, disregard that score (do not use that to compute the average). Round the answer to 2
decimal places. Assume not two students have the same name and every student will have at least
one valid test. If the name of the student passed in is not in the file, return 0. Assume the passed in
filename is a valid file.
Test Cases:
>>> find_avg("scores1.txt", "Iron Man") 95.44 >>> test1 = find_avg("scores1.txt", "Iron Man") >>> print(test1) 95.44 >>> test2 = find_avg("scores2.txt", "Wonder Woman") >>> print(test2) 97.86
>>> test3 = find_avg("scores1.txt", "Superman")
>>> print(test3) 0.0
Function name: make_roster
Parameters: students (str), filename (str)
Return value: None
Description: Take in a string of students. The format of the students will be First Last, First Last,
First Last. Write the names of the students to the file specified by the parameter. Write each line in
the format Last, First. Each student should be in a different line, and the students should be sorted
alphabetical by last name. Make sure there is no newline character after the last student
Test Cases:
>>> make_roster("Caroline Kish, David Wang, First Last", "out1.txt")
Kish, Caroline
Last, First
Wang, David
>>> make_roster("Rodrigo Mejia, Daniel Marcos, Daniel Barrundia", "out2.txt")
Barrundia, Daniel
Marcos, Daniel
Mejia, Rodrigo
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started