Here's a crude attempt:
read -r pid cpu rest < <(ps -eo pid -eo pcpu -eo command |grep python |grep pycode.py)
if (( ${cpu%.*} < 5 )) ; then
kill -TERM $pid
fi
We use `${cpu%.*}` to truncate it to an integer, since bash can't handle floats. This only runs once; if you want to keep it going, put it on a cron job, or put it in a loop with `sleep 5` or whatever.