import numpy as np
def Ratio(img):
a = 0
for row in range(len(img)):
for col in range(len(img[0])):
if img[row][col]==True:
a = a+1
total = img.shape[0] * img.shape[1]
return a/total
a = np.array([[ 1, 0, 1, 1 ],[0, 1, 0, 1 ],[ 1, 1, 1, 0 ]])
print(Ratio(a))
aW1wb3J0IG51bXB5IGFzIG5wCgpkZWYgUmF0aW8oaW1nKToKICAgIGEgPSAwCiAgICBmb3Igcm93IGluIHJhbmdlKGxlbihpbWcpKToKICAgICAgICBmb3IgY29sIGluIHJhbmdlKGxlbihpbWdbMF0pKToKICAgICAgICAgICAgaWYgaW1nW3Jvd11bY29sXT09VHJ1ZToKICAgICAgICAgICAgICAgIGEgPSBhKzEKICAgIHRvdGFsID0gaW1nLnNoYXBlWzBdICogaW1nLnNoYXBlWzFdCiAgICByZXR1cm4gYS90b3RhbAogICAgCmEgPSBucC5hcnJheShbWyAxLCAwLCAxLCAxIF0sWzAsIDEsIDAsIDEgXSxbIDEsIDEsIDEsIDAgXV0pCgpwcmludChSYXRpbyhhKSk=