The derivative of an exponential function of the form $$a^x$$ is

$\frac{d}{dx}a^x = (\ln a)a^x$

from sympy import *
from sympy.abc import x

expr = 2**x
expr2 = 3**(2*x)

diff(expr)
## 2**x*log(2)
diff(expr2)
## 2*3**(2*x)*log(3)

The derivative of a function of the form $$\log_ax$$is

$\frac{d}{dx}\log_a x = \frac{1}{\ln a} \cdot \frac{1}{x}$

expr3 = log(x, 8)
expr4 = log((x**2 + 1), 3)

diff(expr3)
## 1/(x*log(8))
diff(expr4)
## 2*x/((x**2 + 1)*log(3))