The best thing to do is to come out with it--don't let them find out from your teacher or through an online communication. Admit if you didn't study or could have put in more effort. However, if you are struggling with a subject, be sure to tell them that and let them know that you need additional help.