convert partial Week1_Lecture2 matlab codes into python codes