I want to create a Python class which stores the name, surname and grades of a student and checks whether the grades are in the correct range or not (0-10).
Is there any way to change the attributes which are greater than 10 to 0 (not one by one)?
class Student:
def __init__(self, name, lastName, programming, algebra,
calculus, physics, writing):
self.name = name
self.lastName = lastName
self.programming = programming
self.algebra = algebra
self.calculus = calculus
self.physics = physics
self.writing = writing
def check(self):
if self.programming or self.algebra or self.calculus or self.physics or self.writing not in range(11):
#Change the value of the attributes which are > 10 to 0
#Is there any way to do it apart from this one?
#if self.programming not in range(11):
#self.programming = 0
#if self.algebra not in range(11):
#self.algebra = 0
...................