You will write functions that use the Pythagoras theorem: the hypotenuse, a test that names the kind of triangle, and a search for right triangles with whole-number sides.
Your tasks.
hypotenuse, return the length of the hypotenuse of a right triangle with legs a and b.kind, sort the three sides, compare the square of the longest with the other two squares added, and return "right", "acute" or "obtuse".count_triples, return how many whole-number right triangles have a hypotenuse of limit or less. Count each triangle once, with a <= b < c. Then set n_50 to the count for limit = 50.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…