-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.py
More file actions
29 lines (27 loc) · 710 Bytes
/
Copy pathclass.py
File metadata and controls
29 lines (27 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# class person:
# name = 'abc'
# gender= 'male'
# def showinfo(self):
# print('Name: ', self.name )
# print('gender: ', self.gender)
# p1=person()
# p1.showinfo()
class person:
counter=0
def __init__(self, a='Ravi', b= 'male'):
self.name= a
self.gender= b
person.counter= person.counter+1
def showinfo(self):
print('Name: ', self.name)
print('Gender: ', self.gender)
@classmethod
def showcount(cls):
print('No. of persons so far= ', cls.counter)
p1= person('sophie', 'female')
p1.showinfo()
p2= person('stefen', 'male')
p2.showinfo()
p3= person()
p3.showinfo()
person.showcount()