You will write three functions that name a quadrilateral from its four corners. The checker uses a rectangle, a rhombus, a square, a plain parallelogram and a shape that is not a parallelogram.
The idea. In a parallelogram , . A rectangle has equal diagonals. A rhombus has equal adjacent sides. A square has both. Squared lengths keep the numbers exact.
Your tasks.
sq(p, q). Return the squared distance between two points.is_parallelogram(a, b, c, d). Return True if the diagonals have the same midpoint.classify(a, b, c, d). Return one of "not a parallelogram", "parallelogram", "rectangle", "rhombus" or "square".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…