solving several problems in python