写一个 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) 蟒菱区输出
Enter Rhombus First Diagonal = 25
Enter Rhombus Second Diagonal = 28
The Area of a Rhombus = 350.000在这个 Python 程序中,我们创建了一个 cal 菱形面积函数来寻找菱形面积。
# 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) 原创文章,作者:DLKMX,如若转载,请注明出处:https://www.506064.com/n/317760.html
微信扫一扫
支付宝扫一扫