【发布时间】:2019-12-01 11:18:38
【问题描述】:
我是整个编程的新手,慢慢地在互联网上找到了一些东西,但我似乎找不到解决方案,或者只是不明白。为什么程序不会读取其他 elif 语句?这是我的第一个项目。生病感谢任何提示和建议。欢迎提出任何建议和意见,谢谢!
#inputing
unknown = " "
while unknown != "exit":
unknown = input("Please enter unknown: ").lower()
angle = int(input("Please enter given angle: "))
#if base
if unknown == "base" or "a":
side = input("Height(b) or Hypotenuse(c)? ").lower()
if side == "height" or "b":
height = int(input("Please enter given height: "))
base = int(height * tan(radians(angle)))
print(">> The base is: " + str(base))
else:
hypotenuse = int(input("Please enter given hypotenuse: "))
base = int(hypotenuse * cos(radians(angle)))
print(">> The base is: " + str(base))
#if height
elif unknown == "height" or "b":
side = (input("Base(a) or Hypotenuse(c)? ")).lower()
if side == "base" or "a":
base = int(input("Please enter given base: "))
height = int(input(base * tan(radians(angle))))
print(">> The height is: " + str(height))
else:
hypotenuse = int(input("Please enter given hypotenuse: "))
height = int(hypotenuse * cos(radians(angle)))
print(">> The height is: " + str(height))
elif unknown == "exit":
break
else:
print("I don't understand that..")
【问题讨论】:
标签: python-3.x math trigonometry