Here first we create a class Student and then we will create some objects of this class .
In this question we have to find that how many objects of the class Student are exit.
So let's start the coding
In this question we have to find that how many objects of the class Student are exit.
So let's start the coding
Code:-
# student class
class Student:
count=0
def __init__(self):
Student.count=Student.count+1
# object 1
s1=Student()
# object 2
s2=Student()
# object 3
s3=Student()
print("Total number of objects of the class is : ",Student.count)
Output:-
Here the output will be the total number of objects which we created in the program . As we can see here we are creating three objects s1, s2, and s3 . So the output of the program will be 3 . lets check what will be the output of the program.
Total number of objects of the class is : 3
See more:-
1) Very Cool numbers | Hacker earth solution
2) Birthday party | Hacker earth solution
0 Comments