coding algorithms in python