+ 2

who can help me with exercise 20.3 of Python

Homework: The Pythagorean theorem says: In a right angled triangle, the square on the side of the hypotenuse is equal to the sum of the squares on the other two sides. Write a program that takes the lengths of the sides of the triangles as inputs and outputs, whether our triangle is right or not. If the triangle is a right angle, the program should return "At Right Angles", and "Not At Right Angles" if it is not. Input example: 3 4 7 output example: Not at right angles Clue: Take the 3rd input (variable side3 in the sample code) as the longest side, which will represent the hypotenuse if the triangle is at right angles. This is my exercise: side1 = int(input()) side2 = int(input()) side3 = int(input()) if (side3 == (side2 + side1)): print("right angled") else: print("Not right-angled")

14th Jan 2022, 5:40 PM
Jefferson Jesus Beleño Suarez
Jefferson Jesus Beleño Suarez - avatar
7 Respostas
+ 6
side1 = int(input()) side2 = int(input()) side3 = int(input()) if (side3 **2 == (side2 + side1)**2): print("At Right Angles") else: print("Not At Right Angles") I advise you to show this video to understand Pythagorean theorem https://www.khanacademy.org/math/cc-eighth-grade-math/cc-8th-geometry/cc-8th-pythagorean-theorem/v/the-pythagorean-theorem if the program requirements need to make function so the following the solution will become side1 = int(input()) side2 = int(input()) side3 = int(input()) def triangle_type(x,y,z): if (z **2 == (x + y)**2): return "At Right Angles" else: return "Not At Right Angles" triangle_type(side1, side2, side 3) Note: You can use Math.pow() instead of using exponent (**) and make sure that you import Math module
14th Jan 2022, 5:52 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 3
Jefferson Jesus Beleño Suarez Right Angle formula a * a + b * b = c * c;
14th Jan 2022, 5:53 PM
AÍąJ
AÍąJ - avatar
+ 2
Farmula? Jefferson Jesus Beleño Suarez also if it is code coach excersize, then it expect exact output as mentioned in description (spelling, capitazation,.. Etc).. You are trying to print "right angled", "Not right-angled" , but description says to print - "At Right Angles", "Not At Right Angles".
14th Jan 2022, 6:13 PM
Jayakrishna 🇼🇳
14th Jan 2022, 6:29 PM
Jefferson Jesus Beleño Suarez
Jefferson Jesus Beleño Suarez - avatar
+ 1
Solomoni Railoa I need you help. Please.
14th Jan 2022, 5:42 PM
Jefferson Jesus Beleño Suarez
Jefferson Jesus Beleño Suarez - avatar
14th Jan 2022, 7:06 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
0
14th Jan 2022, 7:08 PM
Jayakrishna 🇼🇳