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

 时间:2024-10-13 08:14:15

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计算出矩形的面积
  • Python编程:怎么计算100到200的所有素数
  • python统计字符串中字母数字出现的次数
  • python怎么保存
  • python素数判断代码
  • 使用python语言求1+2+3+...+100的和
  • 热门搜索
    下巴长痘痘是怎么回事 cad角度怎么画 怎么提高学习效率 女性安全期怎么算 脑神经衰弱怎么办 季节性过敏怎么办 个人委托书怎么写 脸上起皮是怎么回事 怎么在网上开店 铁线蕨怎么养