I don't think (from experience) it's particularly difficult to get a doctor's note. Go and see a doctor, explain what was wrong and ask for one. It
might have been better to go on the day you were actually missing the exam... but if you were so ill you couldn't get to the doctors I'm sure they would understand.
Regarding price, I'm not sure. It will depend how long the examination takes, if the doctor needs to do tests etc. I've never had a bill specifically for the certificate, just for the time in the doctor's office (including the writing of the certificate), plus tests.
On a separate note, if you are studying here, and presumably resident here, you should have Swiss health insurance. You have 3 months grace to arrange it, and any medical costs (plus premiums) will be back-dated. The European Health Insurance Card is aimed at tourists. And, as
others have discovered, if you have failed to arrange insurance and have been here for some time, you could find yourself with a hefty bill of back payments.