Since the variable 'a1' is not a Numpy array, both np.sum(a1==1) and np.sum(a1==0) are 0. You are doing 0/0 and that's why you are getting the error. To fix the error, convert 'a1' to a Numpy array.
See the following code:
>>> a1
[1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1]
>>> a1=np.array(a1)
>>> np.sum(a1==1)/np.sum(a1==0)
1.4