用PYTHON判断三角形的类型
工具/原料
PYTHON
方法/步骤
1
首先打开PYTHON,新建一个空白的PY文档。
2
这里要判断的三角形类型有三种,不等边三角形,等腰三角形和等边三角形。
3
先定义三个边都要输入数值。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 = '))
4
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')定义每种情况下需要打印什么结果出来。
5
测试一下不同输入得到的不同结果。
6
如果输入不是数值将会报错,因为定义变量的时候已经规定要要输入什么了。
注意事项
注意四个空格的间隔