You will write functions that divide a segment in a given ratio, find a midpoint, and test whether three points lie on one straight line. The checker uses the points of the lesson and of the problems.
The idea. If , then for each coordinate. A negative gives an external division. Three points are collinear when and have proportional components.
Your tasks.
divide(A, B, m, n). Return the point as a tuple of three numbers.midpoint(A, B). Use divide with .collinear(A, B, C). Return True when and are parallel. Compare every pair of components by cross-multiplying, so that a zero component does not cause trouble.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…