如何使用 python 查找用户输入的自然日志?
import math
def log_e(power_of_e):
math.log = power_of_e
exponent = math.log
return exponent
my_number = float(input('Enter a number and I will give you it\'s natural logarithm:'))
print (log_e(my_number))
如何使用 python 查找用户输入的自然日志?
import math
def log_e(power_of_e):
math.log = power_of_e
exponent = math.log
return exponent
my_number = float(input('Enter a number and I will give you it\'s natural logarithm:'))
print (log_e(my_number))
import math
def log_e(power_of_e):
exponent=math.log(power_of_e)
return exponent
my_number=float(input('Enter a number and I will give you it\'s natural logarithm:'))
print (format(log_e(my_number),'.3f'))
math.log
接受一个可选的第二个参数,这是要使用的基础。math.e
是常数e。把它们放在一起,你会得到:
import math
def log_e(number):
return math.log(number, math.e)