Basic Exercise with Solution on Class Object Method
Tutorial on Class Object & Method
- Basic Exercise on Object Oriented Programming
- Create one class student_kit
Within the student_kit class create one class attribute principal name ( Mr ABC )
Create one attendance method and take input as number of days.
While creating student take input their name .
Create one certificate for each student by taking input of number of days present in class.
print("Name : ",self.name)
print("Principal : ",self.principal_name)
Name : Kalu
Present : 30
Answer these Questions
What is the name of the method used in student_kit class ?
What is the class attribute used in above code ?
Which is the object created in above code ?
How the method got access to class attributes ?
What is the instance attribute in above code ?
What is the data type of the created object ( kalu) ?
How the object can access the instance attribute ?
print(type(kalu)) # <class '__main__.student_kit'>
Tutorial on Class Object & MethodExercise constructor ( basic )
print(kalu.present) # 30
This article is written by plus2net.com team.