Python math.sqrt() method “returns the square root of any number.”
Syntax
math.sqrt(number)
Parameters
x: It is any number such that x>=0. The sqrt() function takes a number as an argument.
Return Value
It returns the square root of a number argument.
Example 1: How to Use math.sqrt() Method
Import math module to work with mathematical operations in Python.
import math
print(math.sqrt(81))
It is the best way to find the square root of any number.
Example 2: Passing positive argument
Another way will give us the same output, but the number must be positive, not negative, and not complex.
num = 49
sq_root = num ** 0.5
print(sq_root)
Output
Example 3: Passing a complex number
To calculate a square root of a complex number in Python, use the cmath module. To use the cmath module, you must import it and then use its sqrt() function.
import cmath
print(cmath.sqrt(1 + 2j))
Output
That’s it.

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.