My students are attempting to use a python function with an if statement in it as part of a differential equation they are solving with desolve_odeint. Unfortunately, of course, Sage executes the python function as soon as they write it and not within the solver. I need help on getting around this. Here is some same code for a simpler case than what they are doing.
def f(x,y):
if x<0.2:
return(0)
else:
return(y*(1-y))
ans=desolve_odeint([SR(1),f(x,y)],[0,0.5],srange(0,10,0.01),[x,y])