Created the two functions asked for in the assignment