如何用PYTHON判断三角形的类型

作者:朋克周 | 创建时间: 2023-05-15
用PYTHON判断三角形的类型...
如何用PYTHON判断三角形的类型

操作方法

首先打开PYTHON,新建一个空白的PY文档。

这里要判断的三角形类型有三种,不等边三角形,等腰三角形和等边三角形。

先定义三个边都要输入数值。 a = int(input("The length of the side a = ")) b = int(input("The length of the side b = ")) c = int(input("The length of the side c = "))

if a != b and b != c and a != c: print("This is Scalene") elif a == b and b == c: print("This is an Equilateral") else: print("This is Isosceles") 定义每种情况下需要打印什么结果出来。

测试一下不同输入得到的不同结果。

如果输入不是数值将会报错,因为定义变量的时候已经规定要要输入什么了。

温馨提示

注意四个空格的间隔
点击展开全文

更多推荐