Почему мой код не дает одинаковые результаты в разных IDE - PullRequest
0 голосов
/ 15 апреля 2020

Я попробовал этот код в PyCharm, но он возвращал область как ноль. Но когда я попробовал в Jupyter Notebook, он показывал правильный вывод. Я только учусь кодировать. В чем может быть причина этой ошибки?

  class Square:
    def __init__(self, height ="0", width="0"):
        self.height = height
        self.width = width
    @property
    def height(self):
        print("Retrieve the height value")
        return self.__height
    @height.setter
    def height(self,value):
        if value.isdigit():
            self.__height = value
        else:
            print("Enter a number for height")


    @property
    def width(self):
        print("Retrieve the width value")
        return self.__width
    @width.setter
    def width(self,value):
        if value.isdigit():
            self.__width = value
        else:
            print("Enter a number for width")


    def get_area(self):
        return int(self.__height) * int(self.__width)


def main():
    square =Square()
    height = input("Enter the height")
    width = input("Enter the width")
    square.height = height
    square.width = width
    print("Height is ", square.height)
    print("Width is ", square.width)
    print("Area is ", square.get_area())


main()    
...