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

寫一個(gè) Python 程序,如果給出兩個(gè)角,用一個(gè)實(shí)例來(lái)求三角形的角。
如果給出兩個(gè)角,Python 程序可以找到三角形的角示例 1
這個(gè) python 程序幫助用戶輸入三角形的兩個(gè)角度。接下來(lái),我們從 180°減去這兩個(gè)角度,因?yàn)槿切沃兴薪嵌鹊目偤? 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 程序使用兩個(gè)角度查找三角形的角度示例 2
這個(gè) 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)頁(yè)標(biāo)題:Python程序:給定兩個(gè)角的情況下計(jì)算三角形的角
轉(zhuǎn)載源于:http://www.dlmjj.cn/article/dhdiphj.html


咨詢
建站咨詢
