【发布时间】:2016-02-13 03:38:55
【问题描述】:
所以我尝试制作的程序由三个输入组成,分别等于右、等腰或钝角三角形,当我运行我的代码时,我遇到了这个问题。我已经把 int() 放在了所有东西的前面。我做错了什么?
angle_1 = input("What is the degree of the first angle? ")
angle_2 = input("What is the degree of the second angle? ")
angle_3 = input("What is the degree of the third angle? ")
if int(angle_1 or angle_2 or angle_3) == 90:
print("This is a right triangle.")
elif int((angle_1 or angle_2 or angle_3) > 90) and int((angle_1 or angle_2 or angle_3) < 180):
print("This is an obtuse triangle.")
else:
print("This is an acute triangle.")
【问题讨论】:
-
你发明了自己的语法,这与 Python 使用的解释不同。考虑
int(angle_1 or angle_2 or angle_3)。这将对三个角度执行逻辑或,然后将结果转换为int。显然不是你想要的。所以,修复它。