类继承_python3

KiKi设计类继承

http://www.nowcoder.com/questionTerminal/699ba050e2704591ae3e62401a856b0e

class shape:
    __x = 0
    __y = 0

class Rectangle(shape):
    __l = 0
    __m = 0
    def __init__(self, x, y):
        self.__l = x
        self.__m = y
        print(self.GetArea())
    def GetArea(self):
        return self.__l*self.__m

class Circle(shape):
    __r = 0
    def __init__(self, x):
        self.__r = x
        print('{:g}'.format(self.GetArea()))
    def GetArea(self):
        return self.__r**2*3.14

class Square(Rectangle):
    __a = 0
    def __init__(self, x):
        self.__a = x
        print(self.GetArea())
    def GetArea(self):
        return self.__a**2

l, m = map(int, input().split())
r = int(input())
a = int(input())

myRect = Rectangle(l, m)
myCirc = Circle(r)
mySqua = Square(a)
全部评论

相关推荐

12-02 20:08
已编辑
门头沟学院 后端工程师
notbeentak...:孩子,说实话,选择很重要,可能你换一个方向会好很多,但是现在时间不太够了,除非准备春招
点赞 评论 收藏
分享
用微笑面对困难:你出于礼貌叫了人一声大姐,大姐很欣慰,她真把你当老弟
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务