This depends on many factors. For some offences imprisonment is not an option for the court. For other offences, imprisonment is mandatory. For many offences, the court has a discretion as to whether to pass a custodial sentence (i.e. send you to prison) and in deciding how to exercise that discretion will take into account all relevant circumstance.