add solutions for problem 4 and 5 for Python version