class student:
sub =["programming","fwb","co","english"]
def __init__(self,aname,aroll):
self.name = aname
self.roll = aroll
def details(self):
return f"Name is: {self.name}\nRoll no: {self.roll}\n"
def __add__(self, other): # Dundar method
return self.roll + other.roll
def __truediv__(self, other): # Dundar method
return self.roll + other.roll
def __repr__(self): # Dundar method
return f"Student('{self.name}', {self.roll})"
def __str__(self): # Dundar method
return f"Name is: {self.name}\nRoll no: {self.roll}\n"
a= student("Aakash", 40)
b = student("Ravi", 20)
print(a)
Comments
Post a Comment