新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Python程序:計(jì)算菱形面積
創(chuàng)新互聯(lián)python教程:

創(chuàng)新互聯(lián)專(zhuān)注于撫寧企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站開(kāi)發(fā),商城網(wǎng)站開(kāi)發(fā)。撫寧網(wǎng)站建設(shè)公司,為撫寧等地區(qū)提供建站服務(wù)。全流程按需求定制網(wǎng)站,專(zhuān)業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專(zhuān)業(yè)和態(tài)度為您提供的服務(wù)
寫(xiě)一個(gè) Python 程序,用一個(gè)例子找到菱形的面積。這個(gè) Python 示例允許菱形第一和第二對(duì)角線,并計(jì)算菱形面積。
# Python Program to find Rhombus Area
rhombusD1 = float(input("Enter Rhombus First Diagonal = "))
rhombusD2 = float(input("Enter Rhombus Second Diagonal = "))
rhombusArea = (rhombusD1 * rhombusD2)/2
print("The Area of a Rhombus = %.3f" %rhombusArea) 蟒菱區(qū)輸出
Enter Rhombus First Diagonal = 25
Enter Rhombus Second Diagonal = 28
The Area of a Rhombus = 350.000在這個(gè) Python 程序中,我們創(chuàng)建了一個(gè) cal 菱形面積函數(shù)來(lái)尋找菱形面積。
# Python Program to find Rhombus Area
def calRhombusArea(d1, d2):
return (d1 * d2)/2
rhombusD1 = float(input("Enter Rhombus First Diagonal = "))
rhombusD2 = float(input("Enter Rhombus Second Diagonal = "))
rhombusArea = calRhombusArea(rhombusD1, rhombusD2)
print("The Area of a Rhombus = %.3f" %rhombusArea) 名稱(chēng)欄目:Python程序:計(jì)算菱形面積
網(wǎng)址分享:http://m.5511xx.com/article/dhespjo.html


咨詢(xún)
建站咨詢(xún)
