Please help me define the following Class in Python Many tha

Please help me define the following Class in Python. Many thanks for your time!

\"\"\"
A Grade represents a specific score on a specific kind of assessment (and has its own assumedly unique name). This is just a \"container\" type, used to give memorable names to individual grouped sub-values.

class Grade: Define the Grade class.

- def __init__(self, kind, name, percent): Grade constructor. All three
parameters must be stored to instance variables of the same names (kind,
name, and percent). If kind is not one of \"test\", \"lab\", \"project\", or
\"final\" (example: kind==\"survey\"), then raise a GradingError with the message
\"no Grade kind \'survey\'\". (You can skip this exception-raising part until
later).
- kind :: str. Should be something like \"lab\", \"test\", or \"project\".
- name :: str. Could be something like \"L1\", \"T2\", or \"P6\".
- percent :: int. (I chose int to simplify the assignment, but float would
have been useful).

- def __str__(self): returns a human-centric string representation. If
kind==\"test\", name==\"T1\", and percent==97, then the returned string must be
\"test:T1(97%)\" (no padded zeroes).

- def __repr__(self): returns a computer-centric string representation. As is
often the case, we want to construct a string that could be pasted back into
the interactive mode to re-create this object. Given the same example as in
__str__, we need to return the string \"Grade(\'test\', \'T1\', 97)\". Note: we
choose to always use single-quotes.

- def __eq__(self, other): we want to check that two grades are equal (our self
and this other grade). We compare each instance variable like so (this is the
definition!)
- return self.kind==other.kind and self.name==other.name and self.percent==other.percent
\"\"\"

Sample usage:


class Grade:

# start defining here

Solution

program

     

lloyd = {

\"name\": \"Lloyd\",

\"homework\": [90.0, 97.0, 75.0, 92.0],
  
\"quizzes\": [88.0, 40.0, 94.0],

\"tests\": [75.0, 90.0]

}

alice =
{
\"name\": \"Alice\",
  
\"homework\": [100.0, 92.0, 98.0, 100.0],

\"quizzes\": [82.0, 83.0, 91.0],
\"tests\": [89.0, 97.0]

}

tyler = {

\"name\": \"Tyler\",

\"homework\": [0.0, 87.0, 75.0, 22.0],
  
\"quizzes\": [0.0, 75.0, 78.0],

\"tests\": [100.0, 100.0]

}


students = [lloyd, alice, tyler]


def average(numbers):
  
total = sum(numbers)
  
total = float(total)

return total / len(numbers)
  
  
def get_average(student):

homework = average(student[\"homework\"])
  
quizzes = average(student[\"quizzes\"])
  
tests = average(student[\"tests\"])

x = homework * 0.1
y = quizzes * 0.3
z = tests * 0.6
return x + y + z

def get_letter_grade(score):

    if score >= 90:
  return \"A\"
  elif score >= 80:
  return \"B\"
   elif score >= 70:
  return \"C\"
  elif score >= 60:
  return \"D\"
else:
    return \"F\"

def get_class_average(students):

results = []

for student in student

results.append(get_average(student))

  return average(results)

print \"Student Grades:\"

def student_grades(student):

   for student in students:

  return get_average(student)

print get_average(student)

    print student[0]

print \"Class Average:\"

print get_class_average(students)

print get_letter_grade(get_class_average(students))

Please help me define the following Class in Python. Many thanks for your time! \
Please help me define the following Class in Python. Many thanks for your time! \
Please help me define the following Class in Python. Many thanks for your time! \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site