[tutorial] removing blank lines and leading whitespace in code excerpts (Chap. 2 to 4)

In Chapters 2 to 4:
 - Removing unnecessary blank lines at the end of some code excerpts.
 - Removing leading whitespace so that all code samples are consistent
with Chapter (which has no leading space for, e.g., HTML excerpts).
 - Other minor code excerpt cleanup.