Praise the effort not the result. And especially don't make it into identity of the child.
Best: good job studying for that exam.
Meh: good job passing that exam.
Worst: you so smart, everything comes easy to you.