Page 1 of 1

Rückkehrungen und Schwimmer in Python -Funktionen

Posted: 16 Mar 2025, 17:14
by Anonymous
Ich muss eine Funktion erstellen, die einen Satz mit Variablen zurückgibt. Aber wie schließe ich alle speziellen String -Zeichen aus, die ich nicht brauche? (z. B. ( oder, oder ')

Code: Select all

ef area_of_triangle( bottom, height ):
area = 0.5 * bottom * height
return 'The area of a triangle with a bottom of', bottom, 'and a height of', height, 'is', area, '.'
Dies ist vorerst mein Code, aber die Ausgabe enthält immer Klammern, Kommas und Apostrophes. 1.0, '.')
Anstelle von: Der Bereich eines Dreiecks mit einem Boden von 2.0 und einer Höhe von 1.0 beträgt 1.0.>