Printing values of a certain order in Python

I have an array A. I want to print number of values which are of the order: 1e2 and also the specific values. I present the current and expected outputs.

import numpy as np

A=np.array([ 4.22134987e+02,  4.22134987e+02,  4.22134987e+02,  4.22134987e+02,
        4.22134987e+02, -7.07598661e-11, -6.80734822e-11,  8.24084601e-11])

B=A[A==1e2]
print(B)

The current output is

[]

The expected output is

[5,4.22134987e+02]

>Solution :

1e2 is 100.00

import numpy as np

A=np.array([ 4.22134987e+02,  4.22134987e+02,  4.22134987e+02,  4.22134987e+02,
        4.22134987e+02, -7.07598661e-11, -6.80734822e-11,  8.24084601e-11])

B=A[A>=1e2]  #or B=A[A>=100]
[len(B),*set(B)]

#output
[5, 422.134987]

Leave a Reply