Beginner question: Logs?

S

Svens

Hey everyone! I'm a math student working on a short script involving
logs. I have a function on my scientific calculator, and was wondering
if there was a similar funtion in python.

For example:

(log65536)/(log4)= 8

I've searched around a bit and haven't been able to find anything.

Thanks!

-Christian
 
R

Robert Kern

Svens said:
Hey everyone! I'm a math student working on a short script involving
logs. I have a function on my scientific calculator, and was wondering
if there was a similar funtion in python.

For example:

(log65536)/(log4)= 8

I've searched around a bit and haven't been able to find anything.

import math

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
R

Robert Kern

Svens said:
Hey thanks...

Still getting an error message though. Here's what i'm doing:

No, read the tutorial.

import math
math.log10(15625)

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
P

Peter Hansen

Elliot said:
from math import *
log10(15625)

It's always a good idea, especially when answering a beginner's
question, to add the caution that this form ("from xxx import *") has
certain dangers** associated with it, and is widely considered poor
style, and should really only rarely be used. (The math module is
probably one of the few places where some people make an exception,
however, but it's still not a good habit to get into.)

-Peter
 
T

Terry Reedy

import math
math.log10(15625)

To find out the names of function in the math module without checking the
docs, do

To get more info, do

Terry J. Reedy
 
T

Terry Reedy

Peter Hansen said:
It's always a good idea, especially when answering a beginner's
question, to add the caution that this form ("from xxx import *") has
certain dangers** associated with it, and is widely considered poor
style, and should really only rarely be used.

Which is why I often do things like
 
G

Greg Ewing

Peter said:
It's always a good idea, especially when answering a beginner's
question, to add the caution that this form ("from xxx import *") has
certain dangers** associated with it, and is widely considered poor
style, and should really only rarely be used.

Better still, don't even *mention* it to a beginner.
They don't need to know about it. At all. Really.
 
R

Robert Kern

Greg said:
Better still, don't even *mention* it to a beginner.
They don't need to know about it. At all. Really.

Well, the OP's use is precisely why "from xxx import *" exists: the
interactive prompt.

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
P

Peter Hansen

Robert said:
Greg Ewing wrote:
[about the "from xxx import *" syntax]
Well, the OP's use is precisely why "from xxx import *" exists: the
interactive prompt.

In that case (and, really, any time) Terry's solution is quite suitable
and an excellent substitute. Even at the interactive prompt some of the
dangers (mostly the potential for name collisions) of "from xxx import
*" are still present.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,240
Messages
2,571,211
Members
47,849
Latest member
RoseannKoz

Latest Threads

Top