a PLA algorithm in python