import sympy as sym
from sympy import Function # Import of Function class
# Defining symbols:
f = sym.symbols('f', cls=Function)
t, f_init, K, U = sym.symbols('t, f_init, K, U')
# Defining the differential equation:
diff_eq = f(t).diff(t) - K*U
# Solving and displaying the diff eq:
f_t = sym.dsolve(diff_eq, f(t), ics={f(0):f_init})
print('f_t =', f_t)