In a motor, a current-carrying loop is placed in a magnetic field. The interaction between the current in the loop and the magnetic field produces a torque on the loop, causing it to rotate. The rotating loop is connected to a shaft, which can be used to perform mechanical work. Therefore, option d, "A shaft connected to the rotating coil is attached to some external device," is the correct answer. The motor's mechanical energy is transferred to the external device through the shaft, allowing the motor to perform mechanical work.