编写一个 Python 程序,通过实际示例查找已知两角的三角形的另一角。
Python 编程:已知两角求三角形另一角 示例
此 Python 程序帮助用户输入三角形的两个角。接下来,我们从 180 中减去这两个角,因为三角形所有角的和为 180。
# Python Program to find Angle of a Triangle if two angles are given
a = float(input('Please Enter the First Angle of a Triangle: '))
b = float(input('Please Enter the Second Angle of a Triangle: '))
# Finding the Third Angle
c = 180 - (a + b)
print("Third Angle of a Triangle = ", c)

Python 编程:使用两个角求三角形角度 示例 2
此 Python 三角形角度查找代码与上面相同。但是,我们使用 函数 的概念将三角形角度 程序 逻辑分开。
# Python Program to find Angle of a Triangle if two angles are given
def triangle_angle(a, b):
return 180 - (a + b)
a = float(input('Please Enter the First Angle of a Triangle: '))
b = float(input('Please Enter the Second Angle of a Triangle: '))
# Finding the Third Angle
c = triangle_angle(a, b)
print("Third Angle of a Triangle = ", c)
Python 三角形角度输出
Please Enter the First Angle of a Triangle: 45
Please Enter the Second Angle of a Triangle: 95
Third Angle of a Triangle = 40.0