Python 我需要帮助查找用户生成输入的自然日志
如何使用python查找用户输入的自然日志Python 我需要帮助查找用户生成输入的自然日志,python,math,input,eulers-number,Python,Math,Input,Eulers 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)) math.lo
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))
math.log
采用可选的第二个参数,该参数是使用的基础math.e
是常数e。把它们放在一起,你会得到:
import math
def log_e(number):
return math.log(number, math.e)
您的函数从未实际调用
math.log()
。相反,它只是返回您传入的值,并在过程中关闭math.log()
函数。您应该看一些关于如何调用函数的基本教程。我删除了您的标记,因为[logging]
根本不意味着使用对数。[e]
的含义也有所不同,如果您将鼠标悬停在标签上,它将显示提示,说明标签代表什么。。。。
import math
def log_e(number):
return math.log(number, math.e)