趣味导学Python——类与对象(一)
来源:互联网 发布:物流软件供应商 编辑:程序博客网 时间:2024/05/17 01:12
<pre name="code" class="python">#coding:utf8 import turtle class Things:#定义“东西”类 pass class Inanimate(Things):#定义”非活动事物“类 pass class Animate(Things):#定义“活动事物”类 pass class Slidewalks(Inanimate):#定义”人行道“类 pass class Animals(Animate):#定义”动物“类 def breathe(self): print "breathing" def move(self): print "moving" def eat_food(self): print "eating food" class Mammals(Animals):#定义”哺乳动物“类 def feed_young_with_milk(self): print "feeding young" class Giraffes(Mammals):#定义”长颈鹿“类 def __init__(self,spots): self.giraffe_spots=spots def find_food(self): self.move() print "I've found food!" self.eat_food() def eat_leaves_from_tree(self): print "eating leaves" def dance_a_jig(self): self.move() self.move() self.move() self.move() ozwald=Giraffes(100)gertrude=Giraffes(150)print ozwald.giraffe_spotsprint gertrude.giraffe_spots'''avery=turtle.Pen()kate=turtle.Pen()avery.forward(50)avery.right(90)avery.forward(20)kate.left(90)kate.forward(100)jacob=turtle.Pen()jacob.left(180)jacob.forward(80)'''msg=raw_input("Please press Enter key over!")
0 0
- 趣味导学Python——类与对象(一)
- 趣味导学Python——画图(一)
- 趣味导学Python——画图(二)
- 趣味Python入门(一):初识Python
- 从CSDN的趣味题学PYTHON
- 蓝桥杯——趣味整数问题一(2017.1.30)
- 蓝桥杯——趣味数组问题一(2017.2.5)
- 蓝桥杯——趣味逻辑推理一(2017.2.16)
- java趣味算法(一)——约瑟夫问题
- C++面向对象(一)——类与对象
- 趣味猜猜(一)
- 趣味数组(一)
- 趣味理解ADO.NET对象模型—《.NET深入体验与实战精要》
- 菜鸟学Python(一)
- 一起学python(一)
- 初识ACM——学习与趣味
- 趣味理解:三层架构与养猪—
- Python 对象特殊方法:(一)对象创建与销毁
- 2个比较经典的PHP加密解密函数分享
- abap 指针使用的一个小例子
- IOS ui基础 uibutton
- 关于后盾网yii框架的学习小结(6)--数据库连接配置与模型定义与后台登陆验
- python3.4 + Django1.7.7 表单的一些问题
- 趣味导学Python——类与对象(一)
- cocos2dx 学习笔记
- php与memcached服务器交互的分布式实现源码分析
- 我的Nexus4终于升级到了android5.1了
- test
- 新购物时代:购物场景与场景购物
- 购物车类-未完成
- 二分匹配 HDU1469 COURSES
- Android studio 出现错误Androidmanifest xml does not exist or has incorrect root tag