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

Coding Problem 4.4.9 (Advanced) (External resource) .0 points possible GetGrade.

ID: 3703059 • Letter: C

Question

Coding Problem 4.4.9 (Advanced) (External resource) .0 points possible GetGrade.py SubmitRun Grades Reset 1 #irite a function called get-grade that will read a Console output will be displayed here 2 #given -cs1391 file and return the student.s grade 3#To do this, we would recommend first pa ss the 4 #filename to your previously-written reader() function. 5#then use the list that it returns to do your 6#calculations. You may assune the file is well-formed 8#A student's grade should be 100 times the sum of each 9#individual assignment's grade divided by its total #multiplied. by its weight. So, if the .cs1301 just had 11 #these two lines: 12|# 14 #2exam 23859 e.4 15 # 16 "Then the result would be 72: 17|# 18 # (88 / 100) * 0.6 + (30 / 50) * 0,4 .?.72 . 100 . 72 20 21 arite your function here! 23 24 25 #Belaw are some lines of code that hill test your 26#You can change the value of the variable(s) to test your function 28| # 29 If your function works correctly, this will originally 30 #print: 91.55 31 print (get_grade(..sample.cs13e1")) 34 35 36

Explanation / Answer

def get_grade(filename): grade = 0 with open(filename, 'r') as f: for line in f: words = line.strip().split() grade += ((float(words[2]) / float(words[3])) * float(words[4])) return grade*100 print(get_grade("sample.cs1301"))

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