[パイソン3]任意の三角形の周囲を計算:私は、Pythonのオンラインコースを、次の、そしてこの活動に立ち往生していています
Assume distance2D(x1, y1, x2, y2) has already been defined. Using it, define a function trianglePerimeter(xA, yA, xB, yB, xC, yC) which calculates the perimeter of a triangle whose three points are (xA, yA), (xB, yB) and (xC, yC).
今distance2Dは、2点間の距離を計算するための関数である。
Assume hypotenuse(a, b) has already been defined. Using it, define a function distance2D(x1, y1, x2, y2) which calculates the distance between the point (x1, y1) and the point (x2, y2).
仰角は、直角三角形の斜辺を計算するだけです。このサイトでは、distance2D関数を使用してtrainglePerimeter関数を定義するよう求めています。
以下は私のコードです。
def trianglePerimeter(xA,yA,xB,yB,xC,yC):
a = distance2D(xA,yA,xB,yB)
b=distance2D(xB,yB,xC,yC)
return a+b
私はコードを変更しようとしましたが、何も動作していないようです。誰かしてください助けて! iが取得
エラーメッセージ:
Before running your code: We defined a function distance2D. Program executed without crashing. The grader said: Running trianglePerimeter(0, 0, 0, 3, 4, 0) … Error: trianglePerimeter(0, 0, 0, 3, 4, 0) has wrong value 10.0, expected 12.0
あなたの関数はどこに 'distance2D'ですか? – qvpham
a、b、cに等しい辺を持つ三角形の場合、周囲を計算する式は非常に奇妙です(a * b - b)。 [適切な数式がある](https://en.wikipedia.org/wiki/Perimeter)。 – zezollo
ポリゴンの「周囲」が何を指しているか知っていますか?使用している式がどこにあるのか分かりませんが、三角形の周囲の計算には関係ありません。 – TigerhawkT3