新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:給定兩個角的情況下計算三角形的角
創(chuàng)新互聯(lián)Python教程:

寫一個 Python 程序,如果給出兩個角,用一個實例來求三角形的角。
如果給出兩個角,Python 程序可以找到三角形的角示例 1
這個 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 求三角形角度的代碼同上。然而,我們使用函數(shù)的概念分離了三角形的角度程序邏輯。
# 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 網(wǎng)站標(biāo)題:Python程序:給定兩個角的情況下計算三角形的角
當(dāng)前網(wǎng)址:http://m.5511xx.com/article/dhdiphj.html


咨詢
建站咨詢
