Trapezoidal Method Python Code