Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Genera una funzione Python in base alla relativa docstring
Puoi eseguire query direttamente su un modello e testare i risultati restituiti quando utilizzi
i diversi valori dei parametri con la console Cloud o chiamando il metodo
l'API Vertex AI in modo diretto.
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"""
Scrivi il corpo della funzione area, seguendo la relativa docstring.
Risposta
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)))
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","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"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2024-10-14 UTC."],[],[]]