code for week 10 exercise sheet.