Python Program to Find Square Root of Number

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

In this tutorial, i will write python programs to find or calculate square root of a number using math power function, and exponent operator.

Python Program to Calculate Square Root of Number

  • Python program to find the square of given number
  • Python program to find given number Using math power() function
  • Python program find a square of given number using Exponent Operator

Python program to find the square of given number

See the following python program to calculate square of a number entered by the user; as shown below:

# Python program to calculate square of a number
# Method 1 (using  number*number)
# take input a number from user
num = int(input("Enter an any number: "))
# calculate square using * operator
sq = num*num
# display result
print("Square of {0} is {1} ".format(num, sq))

Output

Enter an any number:  5 
Square of 5 is 25  

Python program to find given number Using math pow() function

See the following python program to calculate square of a number using math pow() function and entered number by the user; as shown below:

# Python program to calculate square of a number using math module
# importing math module 
import math 
# take input a number from user
num = int(input("Enter an any number: "))
# calculate square using pow() function
square = int(math.pow (num, 2))
# display result
print("Square of {0} is {1} ".format(num, square))

Output

Enter an any number:  7 
Square of 7 is 49  

Python program find a square of given number using Exponent Operator

See the following python program to calculate square of a number using Exponent operator; as shown below:

# Python program to calculate square of a number using Exponent Operator
# take input from user
num = int (input("Enter an any number: "))
# calculate square using Exponent Operator
sq = num**2
# print
print("Square of {0} is {1} ".format(num, sq))

Output

Enter an any number:  9 
Square of 9 is 81  

Recommended Python Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published.