如何用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的和
  • 热门搜索
    圣安地列斯女友攻略 浙江大学城市学院怎么样 有过敏性鼻炎怎么办 日照旅游攻略 蛇是怎么繁殖的 喝茶叶能减肥吗 口袋妖怪火红攻略 手机卡怎么剪成小卡 红烧牛腩的做法 服饰搭配