如何用PYTHON计算出矩形的面积

2025-05-06 18:13:51

1、打开JUPTER NOTEBOOK,新建一个PY文档。

如何用PYTHON计算出矩形的面积

3、width = input("Please input the width: ")length = input("Please input the width: ")size = width * lengthprint(size)也可以用INPUT,但是要注意这样会出现问题的。

如何用PYTHON计算出矩形的面积

5、width = float(input("Please input the width: "))length = float(input("Please input the width: "))size = width * lengthprint(size)如果有小数点的话那么就要用浮点型了。

如何用PYTHON计算出矩形的面积

7、 def size(self): return self.width * self.lengthshape = Retangle(5, 6)print(shape)可以看到这样得不到我们要的结果。

如何用PYTHON计算出矩形的面积

9、只要分开都会出现问题。

如何用PYTHON计算出矩形的面积
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢