we ran such an experimentand typed the results into file named springdata txtdistance (mmass (kg the function in figure reads data from file such as the one we savedand returns lists containing the distances and masses def getdata(filename)datafile open(filename' 'distances [masses [discardheader datafile readline(for line in datafiledm line split('distances append(float( )masses append(float( )datafile close(return (massesdistancesfigure extracting the data from file the function in figure uses getdata to extract the experimental data from the file and then plots it def plotdata(inputfile)massesdistances getdata(inputfilemasses pylab array(massesdistances pylab array(distancesforces masses* pylab plot(forcesdistances'bo'label 'measured displacements'pylab title('measured displacement of spring'pylab xlabel('|force(newtons)'pylab ylabel('distance (meters)'figure plotting the data