Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while True:
- try:
- num1 = int(input("Type in the first parameter: "))
- num2 = int(input("Type in the second parameter: "))
- num3 = int(input("Type in the third parameter: "))
- break
- except ValueError:
- print("You have to type in a number. ")
- while True:
- if num1 > num2 and num1 > num3:
- c = num1
- if c * c == num2 * num2 + num3 * num3:
- print("Your triangle is a pythagorean triangle")
- else:
- print("Your triangle isn't a pythagorean triangle")
- elif num2 > num1 and num2 > num3: # c - hypotenuse
- c = num2
- if c * c == num1 * num1 + num3 * num3:
- print("Your triangle is a pythagorean triangle")
- else:
- print("Your triangle isn't a pythagorean triangle")
- elif num3 > num1 and num3 > num2:
- c = num3
- if c * c == num2 * num2 + num1 * num1:
- print("Your triangle is a pythagorean triangle")
- else:
- print("Your triangle isn't a pythagorean triangle")
- elif num1 == num2 and num2 == num3 and num1 == num3:
- print("There's no such thing as a pythagorean triangle with all sides the same, try again")
- again = str(input("Do you want to continue? [Y/n]n"))
- if again == "Y" or again == "y":
- pass
- else:
- break
- num1, num2, num3 = sorted( [num1, num2, num3] )
- # here the num1 < num2 < num3 so you may use a single check
- if num1 * num1 + num2 * num2 == num 3 * num3 : # etc...
Add Comment
Please, Sign In to add comment