7 Comments
User's avatar
Orith Loeb's avatar

Hi, please find below:

# DDC-8: Test for Pythagorean triplets

a,b,c = map (int, input ("Please enter the three numbers separated by a space: ").split())

def IsPythagorianTriplet (a,b,c):

if (a**2+b**2 == c**2 ):

return print ("This is a pythagorean triplet")

else:

return print ("The three numbers are not a pythogarean triplet")

IsPythagorianTriplet (a,b,c)

Expand full comment
Mike X Cohen, PhD's avatar

Nice solution, Orith. Although your code assumes the third input is the largest.

Expand full comment
Orith Loeb's avatar

Thank you! That's right this is the laid assumption.

Expand full comment
Orith Loeb's avatar

Hii,

I loved 😍 your solution!!

Using list comprehension..twice and slicing. Nice!!

Expand full comment
ACARDIUS's avatar

Hi,

Thank you very much. But I feel like It's not efficient, idk why.

Expand full comment
Orith Loeb's avatar

True. My map () version might be a bit more efficient, but yours is definitely more Pythonic.

I like your approach 👍

Expand full comment