Python Program to Find the Square Root of Number

Python program to find square root of a number; Through this tutorial, i am going to show you how to find the square root of number in python program.

Formula for finding the square root of number; as shown below:

x2 = y 

x = ±√y

Python Program to Find the Square Root of Number

  • Program to find square root of a number in python without using sqrt
  • Python program to find square of a number using sqrt() function

Program to find square root of a number in python without using sqrt

  • Get input the number from user in program.
  • Find square root with this formula sqrt = num ** 0.5 in program.
  • Print the square root of number.
# Python program to find square root of the number
# take inputs
num = float(input('Enter the number: '))
# calculate square root
sqrt = num ** 0.5
# display result
print('Square root of %0.2f is %0.2f '%(num, sqrt))

After executing the python program, the output will be:

PEnter the number: 4
Square root of 4.00 is 2.00

Python program to find square of a number using sqrt() function

  • Import math module in program
  • Get input any number from user in python program.
  • Find square root of number using sqrt() function
  • Print square root
# Python program to find square root of the number
import math  # math module
# take inputs
num = float(input('Enter the number: '))
# display result
print('Square root = ',math.sqrt(num))

After executing the python program, the output will be:

Enter the number: 16
Square root = 4.0

Recommended Python Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published.