fromcollectionsimportnamedtuplefrommathimportsqrt# A point has an x and a y coordinatePoint=namedtuple('Point', 'xy')# A triangle is defined by three pointsTriangle=namedtuple('Triangle', 'abc')defdistance(p,q):
"""Returnsthedistancebetweentheprovidedpairofpoints"""
returnsqrt((p.x-q.x)**2+(p.y-q.y)**2)defperimeter(triangle):
"""Returnstheperimeteroftheprovidedtriangle"""
returndistance(triangle.a,triangle.b)+distance(triangle.b,triangle.c)+distance(triangle.c,triangle.a)defarea(triangle):
"""ReturnstheareaoftheprovidedtriangleusingHeron'sformula"""
docstring에 따라 영역 함수 본문을 작성합니다.
응답
fromcollectionsimportnamedtuplefrommathimportsqrt# A point has an x and a y coordinatePoint=namedtuple('Point', 'xy')# A triangle is defined by three pointsTriangle=namedtuple('Triangle', 'abc')defdistance(p,q):
"""Returnsthedistancebetweentheprovidedpairofpoints"""
returnsqrt((p.x-q.x)**2+(p.y-q.y)**2)defperimeter(triangle):
"""Returnstheperimeteroftheprovidedtriangle"""
returndistance(triangle.a,triangle.b)+distance(triangle.b,triangle.c)+distance(triangle.c,triangle.a)defarea(triangle):
"""ReturnstheareaoftheprovidedtriangleusingHeron'sformula"""
s=perimeter(triangle)/2returnsqrt(s*(s-distance(triangle.a,triangle.b))*(s-distance(triangle.b,triangle.c))*(s-distance(triangle.c,triangle.a)))
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-09-03(UTC)"],[],[]]