Write a Python Program to Find the Square Root

In Python, we can find the square root of a number using the sqrt() function available in the math module.

The sqrt() function takes one argument, which is the number for which we want to find the square root.

Let’s see an example:

import math

number = 16
square_root = math.sqrt(number)

print("The square root of", number, "is", square_root)

Output:

The square root of 16 is 4.0

In the above example, we imported the math module and used the sqrt() function to find the square root of the number 16.

The sqrt() function returned the square root, which was stored in the square_root variable, and then we printed the result using the print() function.

We can also find the square root of a number using the exponentiation operator (**).

The square root of a number can be written as the number raised to the power of 0.5.

Let’s see an example:

number = 16
square_root = number ** 0.5

print("The square root of", number, "is", square_root)

Output:

The square root of 16 is 4.0

In the above example, we used the exponentiation operator (**) to raise the number 16 to the power of 0.5, which is equivalent to finding the square root of 16.

The result was stored in the square_root variable and printed using the print() function.


In conclusion, we can find the square root of a number in Python using the sqrt() function available in the math module or by using the exponentiation operator (**).