<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def printDiagnosticsAfterTraining(exp, verbosity=0):
 """Useful diagnostics a trained system for debugging."""

  print "Number of connected synapses per cell"
  l2 = exp.getAlgorithmInstance("L2")

  numConnectedCells = 0
  connectedSynapses = 0
  for c in range(4096):
    cp = l2.numberOfConnectedProximalSynapses([c])
    if cp>0:
      # print c, ":", cp
      numConnectedCells += 1
      connectedSynapses += cp

  print "Num L2 cells with connected synapses:", numConnectedCells
  if numConnectedCells > 0:
    print "Avg connected synapses per connected cell:", float(connectedSynapses)/numConnectedCells

  print