I just wanted to know if it is ok for one to start a sentence with the words "but" or "and" in formal English?
Most of the works of English literature that we study at school contain examples of sentences that begin with "And" or "But".
Nonetheless, many ESL teachers maintain that it's a stylistic fault.
I myself prefer to believe the writers, rather than the teachers; though an excessive amount of And-ing and But-ing can be irritating.
That said, if you're sitting an exam, or applying for a job, no one will penalize you for not beginning a sentence with "and" or "but". So there may be times when discretion and moderation are the best policy.