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 & Method
Exercise constructor ( basic )
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
15-05-2023 | |
| We greatly appreciate your contribution in sharing your invaluable response. | |