The return statement of some functions might differ from the function definition that were given because I read the docstrings late and now when I tried to correct it, it was giving errors, hence the following function definitions.