(1)Whenever any person is convicted of an offence punishable under section 32, section 33, section 34, section 36, or section 37 and the court convicting him is of opinion that it is necessary to require such person to execute a bond for abstaining from the commission of such offence, the court may, at the time of passing sentence on such person, order him to execute a bond in the prescribed form for a sum proportionate to his means, with or without sureties, for abstaining from the commission of such offences during such period, not exceeding three years, as it thinks fit to fix.