World’s Easiest DIY Electric Train

yeah that spring like copper wire is called solenoid ....whenever the two ends of a solenoid are connected to a battery or by applying potential difference,the current flows in the copper wire ...so produces a magnetic field according to ampere's law...and that magnetic field is given by , B=4 Pi * 10 power(-7)...and this magnetic field pushes the north and south poles in opposite direction and hence causes the motion....