How to select vertices based on their number of edges
Use bmesh

Strongly suggest ditching bpy.ops.mesh operators for bmesh.

Test script, run in object mode, creates the grid mesh and pokes it.  The return of the poke operator gives the new faces as well as the new "poke" vertices.  For example sake have added to a vertex group named "Poke".



Select the vertex group "Poke" and will see that all newly poked, (linked to 4 edges) verts are in it. Alternatively see edit mode answer below.

Object Mode Script

Create a new mesh, load up the newly created bmesh, add a new object with the mesh and link to scene. No operators, no edit mode toggling, no selecting....

import bpy
import bmesh
context = bpy.context
collection = context.collection

bm = bmesh.new()
bmesh.ops.create_grid(bm,
        size=11.95,
        x_segments=30,
        y_segments=30
        )

ret = bmesh.ops.poke(bm, faces=bm.faces)
verts = [v.index for v in ret['verts']]

me = bpy.data.meshes.new("PokedGrid")
bm.to_mesh(me)
ob = bpy.data.objects.new("PokedGrid", me)
vg = ob.vertex_groups.new(name="Poke")
vg.add(verts, 1.0, 'ADD')
context.collection.objects.link(ob)


Edit mode.

Run this test script in edit mode.  Selects all vertices with 8 linked edges.



import bpy
import bmesh

context = bpy.context
me = context.edit_object.data

bm = bmesh.from_edit_mesh(me)
for v in bm.verts:
    v.select = len(v.link_edges) == 8

bmesh.update_edit_mesh(me)


Lastly on distribution, recommend collections.defaultdict 

import bpy
import bmesh
from collections import defaultdict

context = bpy.context
me = context.edit_object.data

bm = bmesh.from_edit_mesh(me)

verts = defaultdict(list)

for v in bm.verts:
    verts[len(v.link_edges)].append(v.index)

print("Total Verts", len(bm.verts))
for k, v in verts.items():
    print(k, "linked edges", len(v))


Output.

Total Verts 1741
3 linked edges 4
5 linked edges 112
8 linked edges 784
4 linked edges 841