Write a class named Student which takes arguments:first_name, last_name, grade, avg_marks(average marks).
and can return: first_name, full_name, grade,and be able to assess perfomance by using avg_marks.
grading scheme:
0-25:B-
26-50:B+
51-75:A-
76-100:A+
class Student:
def __init__(self, first_name, last_name, grade, avg_marks):
self.first_name=first_name
self.full_name=first_name+" "+last_name
self.grade=grade
self.avg_marks=avg_marks
def assess(self):
if 0<=self.avg_marks<=25:
return "B-"
if 26<=self.avg_marks<=50:
return "B+"
if 51<=self.avg_marks<=75:
return "A-"
if 76<=self.avg_marks<=100:
return "A+"
import codewars_test as test
# TODO Write tests
import solution # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Student")
def test_group():
j=Student('John','McCandy',10,50)
k=Student('Karen','Gomez',2,95)
@test.it("First Name")
def fi_test():
test.assert_equals(j.first_name, 'John')
test.assert_equals(k.first_name,'Karen')
@test.it('Full Name')
def fu_test():
test.assert_equals(j.full_name,'John McCandy')
test.assert_equals(k.full_name,'Karen Gomez')
@test.it("Grade")
def cl_test():
test.assert_equals(j.grade,10)
test.assert_equals(k.grade,2)
@test.it(" Assess Average Marks")
def av_test():
test.assert_equals(j.assess(),'B+')
test.assert_equals(k.assess(),'A+')