from sympy import diff from sympy import symbols def func(x): return x**4 x = symbols("x") print(diff(func(x),x))