python based tutorial: Python utilized sqrt () the square root calculation method tutorial

This article describes the use of Python sqrt () method to calculate the square root of course, is learning the basics of Python, a friend in need can refer
sqrt () method returns the square root of x (x> 0).
grammar

The following is the syntax sqrt () method:

import math
 
math.sqrt( x )

Note: This function is not directly accessible, so we need to import math module and static objects math needed to call this function.
parameter

x -- 这是一个数值表达式。

return value

This method returns the square root of x, for x> 0.
example

The following example shows sqrt (use) of the method.

#!/usr/bin/python
import math  # This will import math module
 
print "math.sqrt(100) : ", math.sqrt(100)
print "math.sqrt(7) : ", math.sqrt(7)
print "math.sqrt(math.pi) : ", math.sqrt(math.pi)

When we run the above program, it will produce the following results:

math.sqrt(100) : 10.0
math.sqrt(7) : 2.64575131106
math.sqrt(math.pi) : 1.77245385091

Finally, we recommend a very wide python learning resource gathering, [click to enter] , here are my collection before learning experience, study notes, there is a chance of business experience, and calmed down to zero on the basis of information to project combat , we can at the bottom, leave a message, do not know to put forward, we will study together progress

Published 38 original articles · won praise 29 · views 50000 +

Guess you like

Origin blog.csdn.net/haoxun08/article/details/104828670