Coded the functions using the exmaple given
Commented the code blocks