Calculate logarithm in python

前端 未结 4 1471
鱼传尺愫
鱼传尺愫 2021-02-03 19:05

I am wondering why the result of log base 10 (1.5) in python = 0.405465108108 while the real answer = 0.176091259.

This is the code that I wrote:

         


        
4条回答
  •  一生所求
    2021-02-03 19:29

    If you use log without base it uses e.

    From the comment

    Return the logarithm of x to the given base.
    If the base not specified, returns the natural logarithm (base e) of x.

    Therefor you have to use:

    import math
    print( math.log(1.5, 10))
    

提交回复
热议问题