The math.log() function returns the  logarithm of a given number to the specified base.

math.log(x, base) 

Where, x is the argument to which the logarithm is to be found.  The optional base argument specifies the  base of the  logarithm.

If the base is not given, the function returns the natural logarithm( to the base of e) of the given number.

import math
print(math.log(7)) 
print(math.log(27))
print(math.log(math.pi))

Examples With Base Given

import math

print(math.log(8, 2))
print(math.log(100, 2))
print(math.log(64, 10))
print(math.log(100, 10))

A logarithm is the power to which a number must be raised to get some other number. Since a negative number cannot be expressed as a power of a positive base, the logarithm of a negative number is undefined .  A ValueError is raised if the argument given  to math.log() function is negative. 

import math

math.log(-2)