[课后作业] 第036讲:类和对象:给大家介绍对象 | 课后测试题的答案

[课后作业] 第036讲:类和对象:给大家介绍对象 | 课后测试题的答案

 

 [课后作业] 第036讲:类和对象:给大家介绍对象 | 课后测试题的答案

 

 [课后作业] 第036讲:类和对象:给大家介绍对象 | 课后测试题的答案

#我的代码

class Rectangle:
    length =   float(input('长:'))
    width = float(input('宽:'))

    def setRect(self):
        print("打印长和宽")
        self.length = length 
        self.width = width

    def getRect(self):
        print("这个矩形的长是%.2f,宽是%.2f" % (self.length,self.width))

    def getArea(self):
        return  self.length * self.width
    
p = Rectangle()

 另一个版本

[课后作业] 第036讲:类和对象:给大家介绍对象 | 课后测试题的答案

 

相关文章: