can you take the derivative without knowing the function in python code example

Example 1: how to return the derivative of a function in python

#This prints the derivative of a function
import sympy as sym
x = sym.Symbol('x')
function = x ** 4 + 7 * x ** 3 + 8
derivitive = sym.diff(function)
print(derivitive)

Example 2: python calculate derivative of function

from sympy import Symbol, Derivative

x= Symbol('x')

function= x**4 + 7*x**3 + 8

deriv= Derivative(function, x)
deriv.doit().subs({x:4})