< Kurs:Python < Material < Scripts

Dieses Script berechnet die Hypotenuse beim rechtwinkligen Dreieck unter Verwendung des Hypotenusensatzes, wenn die Länge der beiden Katheden (Seite1, Seite2) angegeben werden.

Script

import math

def hypothenuse (Seite1,  Seite2):
    hypothenuse = Seite1 ** 2 + Seite2 ** 2
    return math.sqrt(hypothenuse)
    
a = input ("Seite 1: ")
b = input ("Seite 2: ")

print "Die Hypothenuse hat eine Laenge von " + str( round ( hypothenuse (a,  b) ) ) + " cm."
This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.