sample code for exercises 1.2.1