Question: IN PYTHON WITHOUT PRINT Write the function distOrigin(x,y) that takes two float values, representing the Cartesian coordinates of a point in 2-space, and returns the
IN PYTHON WITHOUT PRINT
Write the function distOrigin(x,y) that takes two float values, representing the Cartesian coordinates of a point in 2-space, and returns the Euclidean distance of this point from the origin
(0, 0). This is a special case of Euclidean distance between two points.
Cartesian coordinates. Recall Cartesian coordinates (reviewed here), used for representing points relative to a coordinate frame. They were developed by Rene Descartes (bio here), hence the term Cartesian based on a Latinized form of his name. Descartes is perhaps even better known for his work in philosophy.
Euclidean distance. Measurement is fundamental to many problems in computer science, science, and mathematics. The standard method for measuring distance between two points is the Euclidean norm, which represents distance as the crow flies (so it agrees with how you measure distance with a ruler). Euclidean distance is a direct result of the famous Pythagorean Theorem (reviewed here). If one of the points is the origin, the formula for Euclidean distance takes a particularly simple and elegant form.
square root. There are two standard ways to compute the square root of a number in Python: using the math.sqrt function in the math module, or exponentiation with the exponent .5 (recall that 2 is the same as 21/2 or 2.5). So 2 could be calculated using math.sqrt(2) or 2**.5. You may use either form of square root computation, which are equivalent. math.sqrt usually leads to more code clarity, so is recommended here.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
