0
Q:

log in python

Syntax :
math.log(a,Base)

Parameters : 
a : The numeric value
Base :  Base to which the logarithm has to be computed.
Return Value : 
Returns natural log if 1 argument is passed and log with
specified base if 2 arguments are passed.
Exceptions : 
Raises ValueError is a negative no. is passed as argument.
5
# Python code to demonstrate the working of 
# log2(a) 
  
import math 
  
# Printing the log base 2 of 14 
print ("Logarithm base 2 of 14 is : ", end="") 
print (math.log2(14)) 
2
import math 
  
# Printing the log base e of 14 
print(math.log(14)) 
  
# Printing the log base 5 of 14 
print(math.log(14,5)) 

print(math.log2(14))
print(math.log10(14))
1

New to Communities?

Join the community