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
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.
+ 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.
+ 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
+ 1
Thanks Nova, that worked!!! Much appreciated
+ 1
How i did the same thing and 3 still is wrong