x = var('x') 
k = var('k') 
y = function('y',x)
d=diff(y,x) + k*y - exp(-k*x)
sol=desolve(d,[y,x])
sol