Task4.py (breaking code into functions)