python code for grade and step when update