algorithm practice in python