Added the codes for exercise 7.1