add solutions for problem 2 and 3 in Python version