Here is a skeleton of one possible implementation of the final function.
Ordinary comments are indicated by #,
things that remain to be done are indicated
by remarks inside triple quote pairs.

In broad outline, the function profile() walks the synapse along the length of dend. At each node (the 0 and 1 ends plus the center of each segment), the time course of somatic Vm is computed and stored in the vector vm, which is then examined to find its maximum value. The synaptic location and the peak amplitude of the somatically observed epsp are then stored in the vectors location and amplitude, respectively. Finally, the graph g displays a plot of amplitude vs. location.

from neuron import h, gui
from putsyn import putsyn

g = h.Graph()       # for plot of amplitude vs. location

vm = h.Vector()     # to hold the time course of somatic Vm 
                    # evoked by a synaptic input
""" use Vector class .record() to "attach" vm to soma(0.5).v """


def profile():
	global g

	# if you're familiar with matplotlib or other Python graphics libraries,
	# it may be more convenient to use Python lists and those libraries
	# but everything can be done in pure NEURON
	g = h.Graph()
	location = h.Vector()    # store locations along the dendrite
	amplitude = h.Vector()   # store peak amplitude at each location

    # .allseg() loops over all nodes, including 0 and 1
	for seg in dend.allseg():
		putsyn(x)
		""" at this point, vm should contain a record of soma(0.5).v """
		""" find maximum element in vm """
		""" append this to amplitude vector """
		""" append x to location vector """

	""" plot amplitude vs. location """


NEURON hands-on course
Copyright © 1998-2018 by N.T. Carnevale, R.A. McDougl, and M.L. Hines, all rights reserved.