如果我选择缺失角度函数并输入例如 a = 10、b = 10、c = 10,则角度的预期输出为 60 度,但程序的输出为 0.1546...
import math, sys
def missingAngle():
sideA = int(input("size of side a = "))
sideB = int(input("size of side b = "))
sideC = int(input("size of side c = "))
answer = math.acos((sideB**2 + sideC**2 - sideA**2) / (2 * sideB * sideC))
return answer
def missingSide():
angleA = int(input("size of angle A = "))
sideB = int(input("size of side b = "))
sideC = int(input("size of side c = "))
answer = math.sqrt(sideB**2 + sideC**2 - 2 * sideB * sideC * math.cos(angleA))
return answer
missingSideOrAngle = input("Are you trying to work out the missing angle or side?(Angle/Side) = ")
while True:
if missingSideOrAngle.title() == "Angle":
print("Your answer is = " + str(missingAngle()))
sys.exit()
elif missingSideOrAngle.title() == "Side":
print("Your answer is = " + str(missingSide()))
sys.exit()
else:
missingSideOrAngle = input("Please enter a valid string(Angle/Side) = ")
偶然的你
相关分类