Programming_assignment_2.py

Programming_assignment_2.py -...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
STUDENT_SCORE_FILENAME='student_data_prog2.txt' MID1_WEIGHT=0.1 MID2_WEIGHT=0.1 FINAL_WEIGHT=0.15 HW_WEIGHT = 0.05 LAB_WEIGHT = 0.3 PR1_WEIGHT = 0.08 PR2_WEIGHT = 0.08 PR3_WEIGHT = 0.09 PARTICIPATION_WEIGHT = 0.05 #Function to read student data and return lists after parsing def read_data (fname): names = [] student_year = [] mid1 = [] mid2 = [] final = [] HW = [] participation = [] for line in open (fname, 'r'): names.append(line.split()[0]) student_year.append(line.split()[1]) mid1.append(float(line.split()[15])) mid2.append(float(line.split()[16])) final.append(float(line.split()[17])) HW.append(float(line.split()[18])) participation.append(float(line.split()[19])) return names,mid1,mid2,final, HW, student_year,participation #Function to Display the Menu def show_instructions (): print ('------------------------------------------------------------------------------ --------------------------') print ('Welcome to the Student Score Statistics! This will allow you to find specific statistics of each student') print ('Type any of the following: ') print ('a for student lab average') print ('b for student programming assignment average') print ('c for weighted total score') print ('d for overall student grade') print ('e for sorted data') print ('s for additional statistics') #Function to compute average of a given list def avg(scores): total=0 count=0 for i in scores: total += i count += 1 return total/count #Function to computed weigted average of a student score
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
def weighted_student_avg(student_data): return student_data[0]*MID1_WEIGHT + student_data[1]* MID2_WEIGHT + student_data[2]*FINAL_WEIGHT +student_data[3]*LAB_WEIGHT+student_data[4]*PR1_WEIGHT \ +student_data[5]*PR2_WEIGHT+student_data[6]*PR3_WEIGHT+student_data[7]*PARTICIPA TION_WEIGHT+student_data[8]*HW_WEIGHT def get_lab_grades(fname, name, name_list): file= open(fname, 'r') index = name_list.index(name) line = file.readlines()[index] lab_list = [] i = 2 while i < 12: lab_list.append(float(line.split()[i])) i+=1 return (lab_list) def get_pr_grades(fname, name,name_list): file= open(fname, 'r') index = name_list.index(name) line = file.readlines()[index] pr_assignments = [] i = 12 while i < 15: pr_assignments.append(float(line.split()[i])) i+=1 return (pr_assignments) def letter_grade(student_grade): if student_grade >= 93: return ('A') elif student_grade >= 90: return ('A-') elif student_grade >= 87: return ('B+') elif student_grade >= 83: return ('B') elif student_grade >= 80: return('B-') elif student_grade >= 77: return ('C+') elif student_grade >= 73: return ('C') elif student_grade >= 70: return ('C-') elif student_grade >= 67: return ('D+') elif student_grade >= 63: return ('D') elif student_grade >= 60: return ('D-') else: return ('F') def high_low_scores(alist): nmin = alist[0] nmax = alist[0] for i in range(len(alist)):
Image of page 2
if nmin> alist[i]: nmin = alist[i] elif nmax < alist[i]: nmax = alist[i] return(nmin, nmax) def student_data_list (name, fname): student_data = [] name_list,mid1,mid2,final,HW,student_year, participation = read_data(fname) lab_avg = avg(get_lab_grades(fname,name,name_list))
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern