How to write a program to find Square root of a Number in python

How to write a program to find Square root of a Number in python

In this python program, we discuss finding a square root of a number and in this program, we are using the sqrt and pow function.

write a program to find Square root of a Number in python

In this program, the user enters the number and he/she calculates the square root of a number using a math function called sqrt().

import math

number = float(input(" Please Enter any numeric Value : "))

squareRoot = math.sqrt(number)

print("The Square Root of a Given Number {0}  = {1}".format(number, squareRoot))

 

Here is the output of a program

 Please Enter any numeric Value : 256
The Square Root of a Given Number 256.0  = 16.0

write a Python program Square root of a Number using pow()

in this python program, we discuss how to find square root of a number using the pow() as an example √number = number½

import math

number = float(input(" Please Enter any numeric Value : "))

squareRoot = math.pow(number, 0.5)

print("The Square Root of a Given Number {0}  = {1}".format(number, squareRoot))

Here is the output of a program.

Please Enter any numeric Value : 1296
The Square Root of a Given Number 1296.0  = 36.0

Leave a Comment

Verified by MonsterInsights