How to split a Mesh with random_selection I want to split a mesh with random_selection.

My question is: How do I make sure that the "random_selection", selects the faces in a mesh to exact no. as specified by percentage. for example: A 10*10 Mesh contains 100 faces, so 50% of random selection should select exactly 50 faces, but in reality it selects sometime 48, 51, and so on. 
here is my noob Code: 

import bpy
import bmesh

myob = bpy.ops.mesh
m = bpy.context.object
me = m.data

bpy.ops.mesh.select_all(action='TOGGLE')
bm = bmesh.from_edit_mesh(m.data)
face = bm.faces
myob.select_random(percent=50.0)
if len(bm.faces.select) == 100*50/100:
    bpy.ops.mesh.split
else:
    Pass 


I am newbei in Python scripting and blender APIs does not helping me in understanding it clearly on 'How to get access the face information in a mesh' 

len(bm.faces) # Will tell the total faces in a mesh
bm.faces[i].select = true # Will select one face at a time


but, how do I know, How much faces are exactly been selected. Any suggestion:

Here is some code I tried:

for i in range(100):
    if bm.faces[i].select:
        fac.append(bm.faces[i])
        count += 1        
if len(fac) &lt; 50:
    for i in range(50):
        if bm.faces[i].select == False:
            bm.faces[i].select = True
            fac.append(bm.faces[i])
        continue
    bmesh.update_edit_mesh(m.data, True)        
elif len(fac) &gt; 50:
    print (count - 50, "are extra faces." )
    for j in range(100):
        if bm.faces[j].select == True:
            bm.faces[j].select = False
            if bm.faces[j] in fac:
                del fac[j] #problem here
        continue    
    bmesh.update_edit_mesh(m.data, True)
else:
    print ("Exactly 50 faces are selected")


I somehow manage to select missing faces to make them 50 faces, but how do I deselect and remove them from list of selected faces.
Here is another take, that randomly selects from all faces using randint(0, len(faces)) pops the selected face from faces list and adds to selected until the desired length is achieved. 

import bpy
from random import randint

context = bpy.context
obj = context.edit_object
mesh = obj.data
# check that percent is between 0 and 100.
percent = 40
# test code to run in edit mode
import bmesh
bm = bmesh.from_edit_mesh(mesh)
# deselect all
for f in bm.faces:
    f.select = False
# amount that need to be selected (to nearest int)
select_count = int(percent * len(bm.faces) / 100)
# unselected 
faces = [f for f in bm.faces] # could use f.index
# selected
selected = []

while len(selected) &lt; select_count:
    # choose randomly from faces
    i = randint(0, len(faces) - 1)

    # pop and select
    f = faces.pop(i)
    f.select = True
    selected.append(f) # or use f.index
bmesh.update_edit_mesh(mesh)

print("Selected %d of %d" % (len(selected), len(bm.faces)))