0

What am I doing wrong?

https://code.sololearn.com/c1bo7rPsZ50W/?ref=app Hi everyone. I'm trying the Else Statement V test on Sololearn and test cases 1, 2, and 4 are successful with my code above, but not test case 3 which is locked. Its driving me crazy, anyone see the issue? The challenge is as follows: Pythagoras theorem says: In a right-angled triangle, the square of the hypotenuse side is equal to the sum of squares of the other two sides. Write a program that takes lengths of triangle sides as inputs, and output whether our triangle is right-angled or not. If the triangle is right-angled, the program should output "Right-angled", and "Not right-angled" if it's not. Sample Input 3 4 7 Sample Output Not right-angled

20th Dec 2020, 5:27 PM
Alex
5 Réponses
+ 8
Try to square the two sides first and then add them like this: if (side1**2 + side2**2) == side3**2 This will be the correct formula for pythagoras theorem.
23rd Dec 2020, 4:43 AM
Nova
Nova - avatar
+ 7
Just modify the if condition to: if (side1 + side2)**2 == side3**2 As it is clearly stated in the pythagoras theorem: "square of hypotenuse is equal to sum of square of two sides." In your code you are not taking the square of sum of sides and square of hypotenuse.
20th Dec 2020, 5:44 PM
Nova
Nova - avatar
+ 1
Thank you for your reply - however even doing this, case 3 (which is hidden) doesn't work, so I don't understand why...maybe it's a bug in sololearn.... Anyway thanks for your reply as it made me look at this differently
22nd Dec 2020, 8:15 PM
Alex
+ 1
Thanks Nova, that worked!!! Much appreciated
23rd Dec 2020, 8:14 PM
Alex
+ 1
How i did the same thing and 3 still is wrong
23rd Jan 2021, 5:11 PM
Ebony Williams
Ebony Williams - avatar