Is it plagiarism to hire a freelance programmer for an assignment but change a lot of it before you submit it? I took freelancer tutor help for a Python programming coursework  during my MS but did not submit the exact code he gave, I refracted it and changed a lot of it. Is it considered plagiarism? 

I am asking this question to clear the self-guilt and to know more about code plagiarism.
If you used code that you paid someone else to write (or found for free online) for an assignment and don't disclose it, then you have plagiarized.

Plagiarism is the practice of using someone else's work and pretending it is your own, in a situation where there is an expectation of originality (as there is in coursework assignments).

If you use someone else's work and you disclose it (by citing it and telling the professor you have done so), and then build on that work by adding your own work, then you haven't plagiarized. You may not have done a good job on the assignment - your professor may decide that the work you have done on your own is not sufficient to earn a good grade, or your professor may set a rule that students are not allowed to use outside sources and then penalize you for not following the parameters of the assignment; but as long as you are honest about the source of the work, it isn't plagiarism. 

But it is absolutely required that you make it clear what part of the work is not your own, and what parts are your original contributions.