LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-06-2008, 04:28 PM   #1
raskol
Member
 
Registered: Mar 2008
Posts: 51

Rep: Reputation: 15
Square root in python?


how do i get the square root of a number in python?
 
Old 04-06-2008, 04:37 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
The function is sqrt from module math
Code:
>>> from math import sqrt
>>> n = sqrt(64)
>>> print n
8.0
 
Old 04-06-2008, 04:42 PM   #3
Tischbein
Member
 
Registered: Oct 2006
Distribution: debian
Posts: 124

Rep: Reputation: 15
4 ** 0.5

(or was it 4 * 0.5? Just kidding...!)
 
Old 04-06-2008, 05:13 PM   #4
raskol
Member
 
Registered: Mar 2008
Posts: 51

Original Poster
Rep: Reputation: 15
what is the adv/dadv of those different methods?
 
Old 04-06-2008, 08:56 PM   #5
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
** is an internal operator. sqrt is a function that you need to import from math module. can you guess which is "faster"?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Python script as root at startup StuL Linux - General 2 03-05-2008 06:33 PM
Does the square root of -1 exist? Poll! 144419855310001 General 60 11-06-2006 03:54 AM
python script needs root chown ability kosuke Programming 5 11-07-2004 05:14 PM
square root problems - script Dimitris Programming 4 09-02-2003 11:05 PM
root square / two solutions - one variable Dimitris Programming 5 08-28-2003 03:47 PM


All times are GMT -5. The time now is 02:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration