Basic algorithm practice using python implementation