kca python code