The sqrt()
function in Pythonreturns the square root of a non-negative number.
Figure 1 shows the mathematical representation of the sqrt()
function.
The
math
module is required to use this function.
sqrt(number)
sqrt()
requires a non-negative number as a parameter.
sqrt()
returns the square root of the number sent as a parameter.
import math#perfect square rootprint "sqrt(4):", math.sqrt(4)print "sqrt(0):", math.sqrt(0)#simple numberprint "sqrt(5):", math.sqrt(5)print "sqrt(4.5):", math.sqrt(4.5)