If you adopt the view that everyone is not perfect and has his own strengths and weaknesses, you won’t think anyone is particularly stupid.
Just like yourself, there must be some aspects that are far surpassed by outstanding people. So are you stupid? no. You have many advantages in other aspects. You cannot just use one flaw to conclude that the whole person is not good.
The same goes for your friends. He passed the exam twice and should be congratulated. No matter what, he has succeeded.