-1

The value of A is

A = 0.4000070095062256

and after that I have the below code to check the value of A

if (A == 0.400):
    print('pass')
else:
    print('Fail')

I want to print Pass. The above code is printing Fail every time. How will i get approx value of A??

Note: In the condition I have to check the value of A with exactly equal to 0.400. and I mean to say I need approx value of A in float.

Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56

1 Answers1

1

You could check, if the distance to 0.4 is less than a given limit, e.g.:

if abs(A - 0.4) < 0.0001:
    print("Pass")
clemens
  • 16,716
  • 11
  • 50
  • 65