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

創(chuàng)新互聯(lián)專注于撫寧企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站開發(fā),商城網(wǎng)站開發(fā)。撫寧網(wǎng)站建設(shè)公司,為撫寧等地區(qū)提供建站服務(wù)。全流程按需求定制網(wǎng)站,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
寫一個 Python 程序,用一個例子找到菱形的面積。這個 Python 示例允許菱形第一和第二對角線,并計算菱形面積。
# 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在這個 Python 程序中,我們創(chuàng)建了一個 cal 菱形面積函數(shù)來尋找菱形面積。
# 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) 網(wǎng)頁題目:Python程序:計算菱形面積
網(wǎng)址分享:http://fisionsoft.com.cn/article/dhespjo.html


咨詢
建站咨詢
