hausaufgabe--python 36-- Basic knowledge of Class

00--Define a Class with properties and related functions and try to create a instance 

 

Running Result:

 

001-- Class 

to reduce duplicate work, we will use class with some variable and common functions, and user can new related instance without rewrite similar codes. 

e.g. we write a class as Animal, with the properties with eyes, mouth, nose.. and functions with eating(), running(), sleeping().... related instances can be cat = Animal(), tiger = Animal(), snake = Animal()...

To create instance with class, the way is similar with call functions. So, to name a class, we start with uper letter, and use small letter for defining a function's name. 

 

 

posted @ 2017-09-05 21:13  ReedyLi  阅读(164)  评论(0编辑  收藏  举报