Question

python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gr...

python 3 question

Project Description
Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gradebook software to keep track of your grades.

Some instructors like to calculate grades based on what is sometimes called a “total points” system. This is the simplest way to calculate grades. A student’s grade is the sum of the points earned on all assignments divided by the sum of the points available on all assignments. For example, suppose that a computer science class has a set of programming projects, quizzes, and tests, and that the sum of the points of all of these assignments is 485 for a semester. A student earns 412 of those points. Their grade is 412/485, or about 84.95 percent.

In a total points system, instructors have to carefully figure out how many points each assignment should be worth, in order to make sure that certain assignments don’t dominate the students’ grades. Some instructors don’t like to worry about the point value of each assignment, and they prefer what is sometimes called a “weighted category” system.

In a weighted category system, the instructor defines two or more categories and assigns a percentage weight value to each category. The sum of the weights adds up to 100. Grades are calculated by taking the average score of assignments in each category, multiplying each of those numbers by the weight for its category, and adding those values together. For example, the computer science class described above could grade with a weighted category system by defining three categories: programming projects, quizzes, and tests. The instructor decides that programming projects should be worth 45 percent, quizzes 10 percent, and tests 45 percent. A student’s average on programming projects is .95, on quizzes is .92, and on tests is .85. The student’s grade is:
PROJECTS QUIZZES TESTS GRADE
(.95 × 45) + (.92 × 10) + (.85 × 45) = 90.2
Each value in parentheses is the portion of the total grade for one category.

In this project, you will complete several classes to create an electronic gradebook that can calculate grades using either the total points system or the weighted category system.

Topics addressed in this project include:

  • Inheritance
  • Polymorphism
  • Collections (you may choose which collection is most appropriate for you to use ex. lists, sets, dictionaries, etc.)

Design Description
Now that you understand the basics of gradebook software, let’s take a look at the basic classes that will be used in this project. They have been designed for you, but it’s important that you understand the design before you attempt to write the code. Here are the classes used in this project, and the methods defined in each class:

  • We have an Assignment class. An Assignment has a name, a number of points possible for the assignment, and a number of points earned for an assignment. You should have the following methods defined in the Assignment class
    • constructor that takes in a description, score, and total (in that order) and sets up the assignment.
    • getDescription()->str: returns the description of the assignment, ex: 'Lab #3: Gradebook Lab'
    • getScore()->float: returns the total points earned by the student
    • getTotal()->float: returns the total points possible for the assignment
    • changeScore(score:float): changes the total points earned by the student
  • We have a CategoryAssignment class. The CategoryAssignment is a subclass of the Assignment class. It has everything that the Assignment class has. In addition, it has the name of the category to which this Assignment belongs. You should also have the method:
    • constructor that takes in a description, category, score, and total (in that order) and sets up the assignment.
    • getCategory()->str: returns the category of the assignment
  • We have a Student class that will represent all the information associated with a student. The Student class will contain a student id number and a list of all their assignments. You must use a list to store the assignments, so we can ensure the assignments are listed in a particular order. The following methods should be included:
    • the constructor shall take in an int as a parameter, and set the student ID to that value. It should also initialize any other field attributes/variables used in the class.
    • getId()->int: returns the student ID number
    • getScore(assignmentName:str)->float: returns the score of an assignment, searching the assignment description for the assignmentName. If the assignment is not found, nothing will be returned.
    • getScores()->list: returns the list of Assignments for this student.  Note: This is an addition to make it easier to access all scores (Assignments) from a client class. This was not included in the original directions, so be sure you are not missing this on your final submission!
      • def getScores(self)->list:  
        return self._scores #Or whatever you named your list!
    • addAssignment(score: Assignment): adds a score to the list
    • changeScore(assignmentName: str, score: float): searches for the assignmentName in the list. If it is found, the score is updated to score, if it is not found, nothing happens.
    • removeScore(assignmentName: str): removes an assignment from the list if found, if not found, nothing happens.
  • Since we’re going to make more than one kind of gradebook, we will define a class named Gradebook that will be the base class. The Gradebook should keep track of a collection of Student objects. The following methods should be implemented:
    • constructor that takes in no parameters, but initializes all field variables used in Gradebook.
    • addStudent(student: Student): adds a student object to the gradebook (you may choose what kind of collection/data structure you wish to use to represent your gradebook). Precondition: student is not currently in the gradebook. Student ID numbers are unique, so no two students can have the same ID number.
    • dropStudent(id: int): searches for student object by ID number, if they are found, then remove them from the gradebook.
    • search(id:int)->Student: searches for a student using their ID number. Returns the Student if found, if not found, does nothing.
    • addAssignment(id: int, score: Assignment): adds score to a student given an id. If the id is not found in the gradebook, nothing happens. If the assignment description already exists, it will remove the old assignment and replace with score.
  • We have TotalPointsGradebook, which is a subclass of Gradebook and uses the total points system of calculating grades. You should implement the methods:
    • constructor that takes in no parameters, but initializes all field variables used in TotalPointsGradebook.
    • writeGradebookRecord(id: int, fileName: str): this will write the gradebook summary for a single student. It will include their ID number, all assignment information (listed in order), in the format: DESCRIPTION\nSCORE/TOTAL, as well as their overall total and percentage. If the id is not a valid id, your fileName will have one line of text in it: "Student Not Found". The following is example output and may not accurately reflect the number of decimal places output by the script, DO NOT ROUND your decimals.
      • Example output file for 12345678
      • 12345678
        Assignment 1
        12/13
        Assignment 2
        14/20
        Assignment3
        5/10
        Total: 31/43
        Percentage: 72.0930233
      • Formatting notes: The ':' should appear immediately after the previous word, and there should be one space AFTER the colon. There should be NO new line character at the end of the Percentage line.
    • classAverage()->float: returns the class percentage average for all students in the gradebook. You will need to calculate the percentage for each student and take the average of all percentages calculated.
  • We have a CategoryGradebook class, which is a subclass of Gradebook and uses the weighted category system of calculating grades. You need to keep track of the different categories and their weighted value. The following methods should be implemented:
    • constructor that takes in no parameters, but initializes all field variables used in CategoryGradebook.
    • addCategory(description: str, weight: float): adds a category to a collection.
    • isBalanced()->bool: returns True if the category weights add up to 100, and false otherwise.
    • writeGradebookRecord(id: int, fileName: str) this will write the gradebook summary for a single student. It will include their ID number, all assignment information, in the format: CATEGORY: DESCRIPTION\nSCORE/TOTAL, as well as the overall totals for the category and percentage. We will calculate the percentage regardless if the weights are balanced, and you do not need to check if they are balanced to output a file. If the id is not a valid id, your fileName will have one line of text in it: "Student Not Found". The following is example output and may not accurately reflect the number of decimal places output by the script, DO NOT ROUND your decimals.
      • Example output file for 12345678 assuming Final: 50%, Midterm: 30%, and Labs: 20%
      • 12345678
        Labs: Lab #1
        15/20
        Labs: Lab #2
        12/15
        Midterm: Exam
        40/55
        Final: Exam
        72/100
        Final: 72.00
        Midterm: 72.7272
        Labs: 77.1428571
        Percentage: 73.246753
      • Formatting notes: The ':' should appear immediately after the previous word, and there should be one space AFTER the colon. There should be NO new line character at the end of the Percentage line.
    • classAverage()->float: returns the class percentage average for all students in the gradebook. You will need to calculate the percentage for each student and take the average of all percentages calculated.

Implementation Notes: You only need to be concerned with the implementation as described above. For other considerations, like, what happens if the student has an assignment that has a category that is not in the CategoryGradebook? What happens if I don't have category assignments in a CategoryGradebook?? The answer to that is.... you don't care. It is up to the script that is implementing the gradebook to handle situations like that, and you are not required to implement your students, assignments, or gradebooks for this lab. You are simply defining what these objects do, and do not need to worry about how they are used by others.

Test Script: You should run the test script to ensure that your class names and methods are all named correctly. It is up to you to thoroughly test your code, whether this is done through another script, or if you feel comfortable, adding to the test file. You will also need to download the sample files to make sure your output matches what it should.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello, here is your code (Text & Screenshot)

Assignment class class Assignment: 2 #constructor def -initー(self, description : 3tr, self.description - description score :#assignment list of students 37 self.assignments:list[] 38 39 def getld (self)-int: return self.id def getScore (self, assign73 class Gradebook: 74 75 0 def init_ _(self): #creating empty student list. 76 self.students[] 78 def addStudent (self, stud109 110 #TotalPointsGradebook class TotalPointsGradebook (Gradebook) 112 113 def init_ _(self): Gradebook._init_(self) 114 11144 for student in self.students: 145 for assignment in student.assignments: 146 score score + assignment.score 147 totaltota

Code(TEXT)

#Assignment class
class Assignment:
    #constructor
    def __init__(self, description:str, score:float, total:float):
        self.description = description
        self.score = score
        self.total = total

    def getDescription(self)->str:
        return self.description

    def getScore(self)->float:
        return self.score

    def getTotal(self)->float:
        return self.total

    def changeScore(self, newScore:float):
        self.score = newScore

#Category assignment
class CategoryAssignment(Assignment):
    #constructor
    def __init__(self,description:str, category:str, score:float, total:float):
        #init the parent class
        Assignment.__init__(self,description,score,total)
        self.category = category

    def getCategory(self)->str:
        return self.category

#student class
class Student:
    #constructor
    def __init__(self,id:int):
        self.id = id
        #assignment list of students
        self.assignments:list = []

    def getId(self)->int:
        return self.id

    def getScore(self, assignmentName:str)->float:
        #iterate through each assignment.
        for assignment in self.assignments:
            #check if assigment description matches,
            #return the score
            if assignment.description == assignmentName:
                return assignment.score

    def getScores(self)->list:
        return self.assignments

    def addAssignment(self, score:Assignment):
        self.assignments.append(score)

    def changeScore(self, assignmentName:str, score:float):
        #iterate through assignment list,
        #if assignment found update the score.
        for assignment in self.assignments:
            if assignment.description == assignmentName:
                assignment.score = score
                return

    def removeScore(self, assignmentName:str):
        for assignment in self.assignments:
            if assignment.description == assignmentName:
                self.assignments.remove(assignment)
                return


#Gradebook class
class Gradebook:

    def __init__(self):
        #creating empty student list.
        self.students = []

    def addStudent(self, student:Student):
        print("adding student with id: ", student.getId())
        self.students.append(student)

    def dropStudent(self, id: int):
        for student in self.students:
            if student.id == id:
                self.students.remove(student)
                return

    def search(self, id:int):
        for student in self.students:
            if student.id == id:
                return student


    def addAssignment(self,id:int, score: Assignment):
        #loop through each student in student list and find the student
        #if student found, loop through each assignment of that student
        #if assignment found replace it with new one and return from this method.
        #else append the score to student.
        for student in self.students:
            if student.id == id:
                for i, assignment in enumerate(student.assignments):
                    if score.description == assignment.description:
                        student.assignments[i] = score
                        return

                student.assignments.append(score)


#TotalPointsGradebook
class TotalPointsGradebook(Gradebook):

    def __init__(self):
        Gradebook.__init__(self)

    #method writeGradebookRecord
    def writeGradebookRecord(self, id:int, fileName:str):
        #open the file with filename
        f = open(fileName, "w+")
        #search for student
        for student in self.students:
            if student.id == id:
                #score and total that will calculate total score.
                score = 0
                total = 0
                for assignment in student.assignments:
                    f.write("{0}\n".format(assignment.description))
                    f.write("{0}/{1}\n".format(assignment.score, assignment.total))

                    score = score + assignment.score
                    total = total + assignment.total

                f.write("Total: {0}/{1}\n".format(score, total))
                f.write("Percentage: {0}".format(score/total*100))
                f.close()
                return
        f.write("Student Not Found")
        f.close()


    def classAverage(self)->float:
        score = 0
        total = 0

        for student in self.students:
            for assignment in student.assignments:
                score = score + assignment.score
                total = total + assignment.total

        return score/total * 100


#For testing
a1 = Assignment("Assignment 1",25,40)
a2 = Assignment("Assignment 2", 30, 40)

s = Student(2)
s.addAssignment(a1)
s.addAssignment(a2)

book = TotalPointsGradebook()
book.addStudent(s)

print("adding student of id 3")
s1 = Student(3)
book.addStudent(s1)

a3 = Assignment("Assignment 1-3",25,50)
book.addAssignment(3,a3)


print("Class average: ", book.classAverage())

book.writeGradebookRecord(2,"student1.txt")
book.writeGradebookRecord(3,"student2.txt")

Output Sample Text File

student1.txt

Assignment 1
25/40
Assignment 2
30/40
Total: 55/80
Percentage: 68.75

student2.txt

Assignment 1-3
25/50
Total: 25/50
Percentage: 50.0
Add a comment
Know the answer?
Add Answer to:
python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gr...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might...

    Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might be worth 40% of your final grade. To calculate the grade for the Assignments category, the teacher takes the percentage earned on the assignments and multiplies it by the weight. So if the student earned a 90% total on the Assignments, the teacher would take 90% x 40, which means the student earned a 36 percent on the Assignments section. The teacher then calculates...

  • please help asap in c++, you dont have to do everything but at least give me...

    please help asap in c++, you dont have to do everything but at least give me a starting idea of how this should look like Write a class Assignment that has private attributes for Name, Possible Points and Earned Points Write a class Student that has private attributes for name and a vector of assignments. The constructor method should require a name. Add a method for get total score that returns the total number of points earned divided by the...

  • This is a C++ Program, I need the program broken up into Student.h, Student.cpp, GradeBook.h, GradeBook.cpp,...

    This is a C++ Program, I need the program broken up into Student.h, Student.cpp, GradeBook.h, GradeBook.cpp, and Main.cpp 1. The system must be able to manage multiple students (max of 5) and their grades for assignments from three different assignment groups: homework (total of 5), quizzes (total (total of 2) of 4), and exams 2. For each student record, the user should be able to change the grade for any assignment These grades should be accessible to the gradebook for...

  • PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything...

    PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...

  • A csv file called COS-206_gradebook.csv is provided for this project (see Course Documents). This file contains...

    A csv file called COS-206_gradebook.csv is provided for this project (see Course Documents). This file contains grades data for 17 students on 20 assessments. These assessments include quizzes, homework assignments, term projects, and tests.First you are strongly encouraged to open this file in Excel to gain an overview of the data. Note the second row contains point totals for the assessments. For instance, the point total for hw0 (Homework 0) is 20 while the point total for hw1 (Homework 1)...

  • Amusement Park Programming Project Project Outcomes Use the Java selection constructs (if and if else). Use...

    Amusement Park Programming Project Project Outcomes Use the Java selection constructs (if and if else). Use the Java iteration constructs (while, do, for). Use Boolean variables and expressions to control iterations. Use arrays or ArrayList for storing objects. Proper design techniques. Project Requirements Your job is to implement a simple amusement park information system that keeps track of admission tickets and merchandise in the gift shop. The information system consists of three classes including a class to model tickets, a...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

  • AA. Final Project - Improved JavaFX GUI Personal Lending Library Description: In this project we will...

    AA. Final Project - Improved JavaFX GUI Personal Lending Library Description: In this project we will improve our personal lending library tool by (1) adding the ability to delete items from the library, (2) creating a graphical user interface that shows the contents of the library and allows the user to add, delete, check out, or check in an item. (3) using a file to store the library contents so that they persist between program executions, and (4) removing the...

  • COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...

    COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see which professor has the highest rating according to student input. You will create a ProfessorRating class consisting of professor Name and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 being the lowest and 5 being the highest. Your program should contain the following functionalities:...

  • Need code written for a java eclipse program that will follow the skeleton code. Exams and...

    Need code written for a java eclipse program that will follow the skeleton code. Exams and assignments are weighted You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT