• API
• FAQ
• Tools
• Archive
daily pastebin goal
5%
SHARE
TWEET

# Untitled

a guest Jul 22nd, 2018 61 Never
ENDING IN00days00hours00mins00secs

1. while True:
2.     try:
3.         num1 = int(input("Type in the first parameter: "))
4.         num2 = int(input("Type in the second parameter: "))
5.         num3 = int(input("Type in the third parameter: "))
6.         break
7.     except ValueError:
8.         print("You have to type in a number. ")
9.
10. while True:
11.
12.     if num1 > num2 and num1 > num3:
13.
14.         c = num1
15.         if c * c == num2 * num2 + num3 * num3:
16.             print("Your triangle is a pythagorean triangle")
17.         else:
18.             print("Your triangle isn't a pythagorean triangle")
19.
20.
21.     elif num2 > num1 and num2 > num3:                             # c - hypotenuse
22.
23.         c = num2
24.
25.         if c * c == num1 * num1 + num3 * num3:
26.             print("Your triangle is a pythagorean triangle")
27.         else:
28.             print("Your triangle isn't a pythagorean triangle")
29.
30.
31.     elif num3 > num1 and num3 > num2:
32.
33.         c = num3
34.
35.         if c * c == num2 * num2 + num1 * num1:
36.             print("Your triangle is a pythagorean triangle")
37.         else:
38.             print("Your triangle isn't a  pythagorean triangle")
39.
40.     elif num1 == num2 and num2 == num3 and num1 == num3:
41.         print("There's no such thing as a pythagorean triangle with all sides the same, try again")
42.
43.         again = str(input("Do you want to continue? [Y/n]n"))
44.
45.         if again == "Y" or again == "y":
46.             pass
47.         else:
48.             break
49.
50. num1, num2, num3 = sorted( [num1, num2, num3] )
51.
52. # here the num1 < num2 < num3 so you may use a single check
53. if num1 * num1 + num2 * num2 == num 3 * num3 : # etc...
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top