-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmisc.py
59 lines (46 loc) · 979 Bytes
/
misc.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
__author__ = 'jszheng'
from calendar import prcal
#year = int(input("Type the year number:"))
prcal(2015)
''' test class attribute'''
class rect:
"""this is a test"""
l = 8
@classmethod
def display(cls):
print(cls.l)
@staticmethod
def disp_msg():
print("Length is 50")
print(rect.__name__)
print(rect.__bases__)
print(rect.__dict__)
print(rect.__doc__)
print(rect.__module__)
i1 = rect()
i1.display()
rect.disp_msg()
i1.disp_msg()
class rect:
n=0
def __init__(self,x,y):
rect.n +=1
self.l=x
self.b=y
def __del__(self):
rect.n -=1
class_name = self.__class__.__name__
print(class_name,' destroyed')
def rectarea(self):
print ('Area of rectangle is ', self.l * self.b)
def noOfObjects(self):
print ('Number of objects are: ', rect.n)
r=rect(3,5)
r.rectarea()
r.noOfObjects()
s=rect(5,8)
s.rectarea()
r.noOfObjects()
del r
s.noOfObjects()
del s