寫 Python 程序求等腰三角形面積。這個 python 示例允許輸入等腰三角形邊的長度,並使用數學公式找到該面積。
# Python Program to find Isosceles Triangle Area
import math
a = float(input("Enter Isosceles Triangle SideLength : "))
b = float(input("Enter the Other Side of Isosceles Triangle : "))
isosceleArea = (b * math.sqrt((4 * a * a) - (b * b)))/4;
print("The Area of the Isosceles Triangle = %.3f" %isosceleArea)
Python 面積的一個 n 等腰三角形輸出
Enter Isosceles Triangle SideLength : 10
Enter the Other Side of Isosceles Triangle : 8
The Area of the Isosceles Triangle = 36.661
在這個 Python 程序中,我們創建了一個等值三角形面積函數來尋找等腰三角形的面積。
# Python Program to find Isosceles Triangle Area
import math
def IsoscelesTriangleArea(a, b):
return (b * math.sqrt((4 * a * a) - (b * b)))/4
a = float(input("Enter Isosceles Triangle Side Length : "))
b = float(input("Enter the Other Side of Isosceles Triangle : "))
isosceleArea = IsoscelesTriangleArea(a, b)
print("The Area of the Isosceles Triangle = %.3f" %isosceleArea)
原創文章,作者:RTBKV,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/315802.html