# This is a sample proj11-test.py program
# There are two requirements:
#   A) Demonstrate all methods (except __repr__ which can only be demonstrated 
#      in the Python shell)
#   B) Include print statements so your output can be read and understood 
#      without reading the code

import classes

print("Create a Grade instance: p01, 70, 0.25")
p1 = classes.Grade("p01",75,0.25)    # tests __init__
print("Print the Grade instance")
print(p1)        # tests __str__
# we cannot test __repr__ in a program, only in the Python shell

# Create another grade instance, let's call it g2
print("Create a Grade instance: p02, 80, 0.50")
p2 = classes.Grade("p02",80,0.50)
print("Print the Grade instance")
print(p2) 

# Maybe create more grades
print("Create a Grade instance: p03, 90, 0.25")
p3 = classes.Grade("p03",85,0.25)
print("Print the Grade instance")
print(p3) 
print(" ")

# Create a Student instance, let's call it s1
s1 = classes.Student(1, "Jack", "Booker", [p1, p2])
Esempio n. 2
0
import classes

participation = classes.Grade('Participation', 95, .2)

quiz01 = classes.Grade('quiz01', 95, .1)
quiz02 = classes.Grade('quiz02', 95, .1)
quiz03 = classes.Grade('quiz03', 100, .1)
essay01 = classes.Grade('essay01', 87.5, .1)
essay02 = classes.Grade('essay02', 81.25, .1)
essay03 = classes.Grade('essay03', 100, .1)

Camille = classes.Student(1,"Camille","Emig",[participation, quiz03,quiz02,quiz01, essay03,essay02,essay01])
print(Camille)
Esempio n. 3
0
import classes

mpl = classes.Grade('MPL', 100, .1)
exam1 = classes.Grade('exam1', 72, .1)
exam2 = classes.Grade('exam2', 63.33, .15)
proj01 = classes.Grade('proj01', 93.33, .015)
proj02 = classes.Grade('proj02', 90, .02)
proj03 = classes.Grade('proj03', 65, .02)
proj04 = classes.Grade('proj04', 92.5, .04)
proj05 = classes.Grade('proj05', 95.56, .045)
proj06 = classes.Grade('proj06', 100, .045)
proj07 = classes.Grade('proj07', 100, .05)
proj08 = classes.Grade('proj08', 88, .055)
proj09 = classes.Grade('proj09', 50, .055)
proj10 = classes.Grade('proj10', 80, .055)
proj11 = classes.Grade('proj11', 90, .055)
exam3 = classes.Grade('exam3', 70, .2)

#rest_of_grade = classes.Grade('rest_of_grade', 87.5, .1)

Elizabeth = classes.Student(1, "Elizabeth", "Schester", [
    mpl, exam1, exam2, proj01, proj02, proj03, proj04, proj05, proj06, proj07,
    proj08, proj09, proj10, proj11, exam3
])
print(Elizabeth)
Esempio n. 4
0
#  Computer Project #11
#
#    Imports classes
#    Tests making a grade
#    Tests making a students
#    Tests adding a grade
#    Tests calculating final grade
#    Makes two students with different final scores
#    Compares students (>,<, =)
#
###########################################################

import classes

print("Testing making a grade")
new_grade = classes.Grade('test', 100, .5)  #test __init__()
print(new_grade, '\n')  #test __str__()

print("Testing making a grade with incorrect parameters")
new_grade_two = classes.Grade(11, 'a', 'b')  #test __init__()
print(new_grade_two, '\n')  #test __str__()

print("Testing making a Student with correct parameters- Grace")
grace_grade_one = classes.Grade('test', 100, .5)  #test __init__()
grace_grade_two = classes.Grade('test2', 50, .5)  #test __init__()
Grace = classes.Student(1, "Grace", "A",
                        [grace_grade_one, grace_grade_two])  #test __init__()
print(Grace)  #test __str__()

print("Testing making a Student with incorrect parameters- No Name"
      )  #test __init__()
Esempio n. 5
0
    #Loops through remaining lines, appending a list of a student's grades
    #to a list of all of the student's grades
    students_grades = []
    for line in grades:
        students_grades.append(line.split())

    #Seperates student ids from the student's grades, maintaining order
    student_ids = []
    for student in students_grades:
        student_ids.append(int(student.pop(0)))

    #Makes a dictionary relating the student ids and the list of Grade objects
    grades_dictionary = {}
    for i in range(len(students_grades)):
        for j in range(len(students_grades[i])):
            students_grades[i][j] = classes.Grade(project_names[j],\
            float(students_grades[i][j]),weights[j])
        grades_dictionary[int(student_ids[i])] = students_grades[i]

    students_list = []
    for line in students:
        #Gets student information from students file
        information = line.split()
        stu_id = information[0]
        stu_first = information[1]
        stu_last = information[2]
        #makes a student object from information in the students file and
        #appends it to a list
        students_list.append(classes.Student(int(stu_id), stu_first, stu_last,\
        grades_dictionary[int(stu_id)]))

    #Sets variables for class average
Esempio n. 6
0
def read_file(fp_students, fp_grades):
    """
    Processes files into grade and student objects. The grade objects are added
    to their respective student object
    fp_students: the students.txt file pointer
    fp_grades: the grades.txt file pointer
    student_list: a list of the complete student objects
    """
    
    student_list, grades_list, students_grades, grade_obj_list = [],[],[],[]
    
    #splits up the lines in the students.txt in order to create student objects
    for line in fp_students:
        stu_id = int(line[:1])
        name1 = line[2:11].strip()
        name2 = line[11:].strip()
        student_list.append(classes.Student(stu_id, name1, name2, []))
    
    for line in fp_grades:
        
        #determine the number of assignments that exist in the grades file
        num = (len(line)-13)/7
        if num%7 > 7/2: #rounds up by adding 1, then rounding down
            num += 1
        num = int(num)
        
        if grades_list == []:
            #initializes the grades_list to have a length equal to the number
            #of assignments
            for i in range(num):
                grades_list.append([])
                
        #splits up the lines in grades.txt in order to create lists of data 
        #that can be turned into grade objects
        for i in range(num):
            grades_list[i].append(line[13+(7*i):13+(7*(i+1))].strip())
    
    #initializes the grade_obj_list to have as many sub-lists as students
    for i in range(len(student_list)):
        grade_obj_list.append([])
    
    for i in range(len(grades_list)):
        students_grades = grades_list[i][2:]
        
        
        #understanding the number of assignments in gradelist, lists of grade
        #objects can be made
        for spot, individual_grade in enumerate(students_grades):
            grade_obj = classes.Grade(grades_list[i][1],int(individual_grade),\
            float(grades_list[i][0]))
            grade_obj_list[spot].append(grade_obj)
    
    #because the students in students list line up with the grade lists in 
    #grade_obj_list, the grade lists at a spot i can be added to the student
    #object at spot i via the Student.add_grade() function
    for i in range(len(student_list)):
        individual_grade_list = grade_obj_list[i]
        student_obj = student_list[i]
        for grade in individual_grade_list:
            student_obj.add_grade(grade)
            
    final_grade = 0
    for student in student_list:
        final_grade = int(student.calculate_grade())
        final_grade_str = "Final grade:{:>5}%{}".format(final_grade, " "*7)
        student.add_grade(final_grade_str)
    return student_list