Efficient Code For Prime Number In Python