472,780 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

Beginner question: Logs?

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

Jul 19 '05 #1
11 2489
Svens wrote:
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
rk***@ucsd.edu

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

Jul 19 '05 #2
Hey thanks...

Still getting an error message though. Here's what i'm doing:
------
import math
log10(15625)
------
-It says that log10 is not defined, but it is since the module is
imported, right?

Jul 19 '05 #3
Svens wrote:
Hey thanks...

Still getting an error message though. Here's what i'm doing:
------
import math
log10(15625)
------
-It says that log10 is not defined, but it is since the module is
imported, right?


No, read the tutorial.

import math
math.log10(15625)

--
Robert Kern
rk***@ucsd.edu

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

Jul 19 '05 #4
Svens wrote:
Hey thanks...

Still getting an error message though. Here's what i'm doing:
------
import math
log10(15625)
------
-It says that log10 is not defined, but it is since the module is
imported, right?


try this:

import math
math.log10(15625)
Jul 19 '05 #5

On Jun 1, 2005, at 9:04 PM, Svens wrote:
Hey thanks...

Still getting an error message though. Here's what i'm doing:
------
import math
log10(15625)
------
-It says that log10 is not defined, but it is since the module is
imported, right?


do either

import math
math.log10(15625)
from math import *
log10(15625)

from math import log10
log10(15625)


-- Elliot Temple
http://www.curi.us/
---
[This E-mail scanned for viruses by Declude Virus]

Jul 19 '05 #6
Elliot Temple wrote:
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
Jul 19 '05 #7
> import math
math.log10(15625)


To find out the names of function in the math module without checking the
docs, do
dir(math) #same for any other module
To get more info, do
help(math) # same for any other module with a doc string


Terry J. Reedy

Jul 19 '05 #8

"Peter Hansen" <pe***@engcorp.com> wrote in message
news:Q7********************@powergate.ca...
Elliot Temple wrote:
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.


Which is why I often do things like
import math as m
m.log...



Jul 19 '05 #9
Peter Hansen wrote:
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.

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
Jul 19 '05 #10
Greg Ewing wrote:
Peter Hansen wrote:
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.


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

--
Robert Kern
rk***@ucsd.edu

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

Jul 19 '05 #11
Robert Kern wrote:
Greg Ewing wrote:

[about the "from xxx import *" syntax]
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.


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
Jul 19 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: J.R. | last post by:
Hi folks, The python can only support passing value in function call (right?), I'm wondering how to effectively pass a large parameter, such as a large list or dictionary? It could achieved...
1
by: Mike Malter | last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I can call that method again later using reflection. I am...
3
by: Neal | last post by:
managed C++ VS 2003 I have a beginner question about windows forms.... I need to call a function when a certain limit has been reached, now with the way VS sets up the .NET windows Form I get...
8
by: ^MisterJingo^ | last post by:
Hi all, I'm attempting to create a login/role system for an application i'm building. My idea is to store an instance of a 'webapp' object in global.asax. This object stores login (username, ID)...
6
by: Andy Leese | last post by:
Beginner Question: ASCII Symbols I am using Borland C++ and programming under DOS. I wish to display the symbols of the early ASCII character set... For example: cout << char(7); ...
4
by: a | last post by:
Dear all vb.net developer I want to know the time I need to master vb.net? I'm beginner
0
by: Daniel T. | last post by:
Carter <cartercheng@gmail.comwrote: When you see "discards qualifiers", more often than not, it means that a const object is begin asked to do something that only non-const objects can do....
2
by: Daniel | last post by:
Looking for a good resource for beginners? books, online anything that will get me started.. what im trying to focus on is building a small program in c# to look thru a few files in a folder...
2
by: roanhn | last post by:
Hello. I've to to write a master's thesis. Currently I deal with php, mysql, ajax. Fate decreed that I've to choose one of this subjects: 1.gdi+ library in .net technology 2.ado.net technology...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.