mardi 17 décembre 2019

Checking if two values are approximately the same in python [duplicate]

I have two functions which give me very small numbers. I want to define a IF statements in which If two values are approximately the same print them otherwise pass

a = (x, y)
b = (h, p)
If a == b:
   print(a, b)
else:
   pass

for this we cannot use ==. How to define it to be close? Because the order of values maybe like a=7e-25, b=1.5e-26

Aucun commentaire:

Enregistrer un commentaire