class student_kit():
principal_name='Mr ABC'
def __init__(self,name):
self.name=name
def attendance(self,days):
self.present=days+10
print("Name : ",self.name)
print("Present :",self.present)
print("Principal : ",self.principal_name)
kalu=student_kit("Kalu")
kalu.attendance(20)
Output
Name : Kalu
Present : 30
print(type(kalu)) # <class '__main__.student_kit'>
print(kalu.present) # 30
Tutorial on Class Object & MethodExercise constructor ( basic )
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.
15-05-2023 | |
We greatly appreciate your contribution in sharing your invaluable response. |