0
点赞
收藏
分享

微信扫一扫

学习-Python面向对象之类的定义和使用

90哦吼 2022-04-14 阅读 84
"""
任务:给定了一个 Dog 类,类中有 foot、weight 和 height 三个属性。请在类的外部输出这三个属性的值。
"""

class Animal:
    foot = 4
    weight = 14
    height = 30
    
# 请在下面的Begin-End之间按照注释中给出的提示编写正确的代码
########## Begin ##########
# 第1步:实例化类
animal=Animal()
# 第2步:输出三个类属性的值
print('foot属性值为:'+str(animal.foot))
print('weight属性值为:'+str(animal.weight)+'kg')
print('height属性值为:'+str(animal.height)+'cm')
 
########## End ##########

给定了一个 Dog 类,类中有 foot、weight 和 height 三个属性。请在类的外部输出这三个属性的值。

举报

相关推荐

0 条评论