Solve the problems by Python