Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Membuat fungsi Python berdasarkan docstring-nya
Anda dapat membuat kueri model secara langsung dan menguji hasil yang ditampilkan saat menggunakan
parameter value yang berbeda dengan Konsol Cloud, atau dengan memanggil
Vertex AI API secara langsung.
fromcollectionsimportnamedtuplefrommathimportsqrt# A point has an x and a y coordinatePoint=namedtuple('Point','x y')# A triangle is defined by three pointsTriangle=namedtuple('Triangle','a b c')defdistance(p,q):"""Returns the distance between the provided pair of points"""returnsqrt((p.x-q.x)**2+(p.y-q.y)**2)defperimeter(triangle):"""Returns the perimeter of the provided triangle"""returndistance(triangle.a,triangle.b)+distance(triangle.b,triangle.c)+distance(triangle.c,triangle.a)defarea(triangle):"""Returns the area of the provided triangle using Heron's formula"""
Tulis isi fungsi area, mengikuti docstring-nya.
Respons
fromcollectionsimportnamedtuplefrommathimportsqrt# A point has an x and a y coordinatePoint=namedtuple('Point','x y')# A triangle is defined by three pointsTriangle=namedtuple('Triangle','a b c')defdistance(p,q):"""Returns the distance between the provided pair of points"""returnsqrt((p.x-q.x)**2+(p.y-q.y)**2)defperimeter(triangle):"""Returns the perimeter of the provided triangle"""returndistance(triangle.a,triangle.b)+distance(triangle.b,triangle.c)+distance(triangle.c,triangle.a)defarea(triangle):"""Returns the area of the provided triangle using Heron's formula"""s=perimeter(triangle)/2returnsqrt(s*(s-distance(triangle.a,triangle.b))*(s-distance(triangle.b,triangle.c))*(s-distance(triangle.c,triangle.a)))
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","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"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-12-06 UTC."],[],[]]