python log()

Paul Rubin phr-n2001d at nightsong.com
Mon Dec 10 17:47:30 EST 2001


"Ian" <Duxbuz at bbtinternet.com> writes:
> Hello I am new to python and am trying to use it to work out a sum
> log(20/7) / log(2)
> which gives result
> 1.0
> 
> I am expecting to get 1.51 as a result, and using different langs such as
> perl or php, I get the desired result of 1.51
> 
> It seems to me that python only goes to a certain decimal place, not as much
> as the other compilers, can this be altered in anyway?

Use 20.0 (or just "20.", ending with a decimal point) to signify a
real number rather than an integer.  So you'd say log(20./7.)/log(2.)
This is common with most programming languages.



More information about the Python-list mailing list