This program defines a Python class "student" with the following attributes and methods:
The program then creates two objects o and a of the "student" class, passing the respective name and age as arguments. The printDetail method is then called on each object to print their details. Finally, the value of the count attribute is accessed using both the class name and an object reference, which returns the same result.
class student: count = 0 def __init__(self, name, age): self.name = name self.age = age student.count += 1 def printDetail(self): print("Name : ", self.name, " Age : ", self.age) @classmethod def total(cls): return cls.count o = student("Joes", 25) o.printDetail() a = student("Raja", 45) a.printDetail() print("Total Admission :", student.total()) print("Total Admission :", o.total())To download raw file Click Here
Name : Joes Age : 25 Name : Raja Age : 45 Total Admission : 2 Total Admission : 2
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions