How can i print out the maximum,minimum and average valence for all the vertices in the selected mesh?
Here is a script to collect the valence of all vertices of an object:

import bpy

def CalcValences( verts, edges ):
    #Initialize the valences with all vertices indexes
    result = {v.index: 0 for v in verts}
    #Add the valences for the vertices of each edge
    for e in edges:
        result[e.vertices[0]] += 1
        result[e.vertices[1]] += 1
    return result

# Get the selected object
obj = bpy.context.object

if ( obj ): # If it exists
    valences = CalcValences( obj.data.vertices, obj.data.edges )
    print( valences )


obj.data.vertices corresponds to the vertices, which each as an index as identifier.

obj.data.edges get the... edges and each edge stores a vertex index pair in vertices[0] and [1].

Concerning min, max and average, this is Python aspect, not Blender...

If more information is needed, please ask in comments.