Python Basics5 (instance and class methods)
class pythontraining :
board="whiteboard"; #class variable
def bookwriting(self,name) :#instance methods
print("bookwriting is"+str(name));
def listening(self,name) :#instance methods
print("listening is"+str(name));
def understanding(self,percentage) :#instance methods
print("understanding is"+str(name));
def boardreading(cls) :#class method
print("class method")
x=pythontraining(); #object x
x.pen="parker";
x.book="rule";
x.bookwriting(x.pen);
x.understanding('90%');
y=pythontraining();
y.pen="reynolds"
y.book="white notebook";
y.bookwriting(y.pen);
y.understanding('80%')
print(pythontraining.board)
pythontraining.bookreading();
board="whiteboard"; #class variable
def bookwriting(self,name) :#instance methods
print("bookwriting is"+str(name));
def listening(self,name) :#instance methods
print("listening is"+str(name));
def understanding(self,percentage) :#instance methods
print("understanding is"+str(name));
def boardreading(cls) :#class method
print("class method")
x=pythontraining(); #object x
x.pen="parker";
x.book="rule";
x.bookwriting(x.pen);
x.understanding('90%');
y=pythontraining();
y.pen="reynolds"
y.book="white notebook";
y.bookwriting(y.pen);
y.understanding('80%')
print(pythontraining.board)
pythontraining.bookreading();
Comments
Post a Comment