python linear regression problem

Solve the entire HW problem. Using python to solve the linear regression problem. And functions are given,