Home » Find square root of a number using exponential operation

Find square root of a number using exponential operation

Find square root of a number using exponential operation

Hello everyone, welcome back to Programming In Python! Here we learn about a Python program that finds the square root of a given number. We find the square root of a number using exponential operations.

Here I calculate the square root by finding the power of the number with 0.5, as you all know that the square root of a number is equal to its power by half. So now I use this way to calculate the result.

One can also find the square root of a number using a built-in function called sqrt(), Look at my other post here which shows the same.

https://www.youtube.com/watch?v=Cvxoc1H2qAI”]

You can watch this video on YouTube here

Program on GitHub

Square Root – Code Visualization

Task :

To find the square root using exponential operation

Approach :

  • Read the input number for which the square root is to be calculated using input() orraw_input().
  • Use exponential operation ** to that number with 0.5
  • The obtained result of the above operation is the required square root.
  • Print the result.

Program on GitHub

Program :

num = float(input('Enter a number: '))

sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f' % (num, sqrt))

Output :

Square root using exponential operation
Square root using exponential operation
Square root using exponential operation
Square root using exponential operation
Square root using exponential operation
Square root using exponential operation

Program on GitHub

 

Master the basics of data analysis in Python. Expand your skillset by learning scientific computing with numpy.

Take the course on Introduction to Python on DataCamp here https://bit.ly/datacamp-intro-to-python

Online Python Compiler

Leave a Reply

Your email address will not be published. Required fields are marked *