Python Def Approxequal X Y Tol Returns True X Y Within Tol Q37161250

Python

def approx_equal(x, y, tol):

Returns True if and only if x and y are within tol of eachother.


Answer


def approx_equal(x, y, tol): return abs(x – y) <= tolprint(approx_equal(1, 2, 1))print(approx_equal(4, 3, 1))print(approx_equal(4, 3, 0.99))print(approx_equal(-1.5, 1.5, 3))

Please let me know if you have any doubts Please upvote this answer. Thanks!!

Please let me know if you have any doubts Please upvote this answer. Thanks!!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.