ALSTOM interview question

Write a code for hysteresis loop.