Python Based On Mathematical Problem