Integrability of a piecewise function

Define if and on .

Prove that the function is integrable.

Proof.

Now, I know that a theorem says that a function that is continuous over a bounded interval is integrable. And I also know that another theorem says that a function that has finitely many discontinuities over a bounded interval is also integrable. So since both x and 2 are continuous, this function is integrable.

Is this right? Should I have a more formal proof? And is it possible to show this is integrable by using the definition or ?