functions are an essential part of programming that allow for code to be re-used, simplified,…