Python Upper Bound Formula