Hello everyone, Welcome back! Here we discuss a very simple python program which finds the square root of a given number using a module called Math and use one of its method sqrt(). In the …<\/p>","author":{"@type":"Person","name":"AVINASH NETHALA","url":"https:\/\/www.programminginpython.com\/author\/avinash\/","image":{"@type":"ImageObject","url":"https:\/\/secure.gravatar.com\/avatar\/ed52e7670d7db94820c7430d324103ccdecb16d86611d5b29064aa9ce25a958b?s=96&d=mm&r=g","height":96,"width":96},"sameAs":["https:\/\/www.programminginpython.com\/"]}}

Home » Find square root of a number using sqrt() function

Find square root of a number using sqrt() function

Find square root of a number using sqrt() function Find square root of a number using sqrt() function

Hello everyone, Welcome back! Here we discuss a very simple python program which finds the square root of a given number using a module called Math and use one of its method sqrt().

In the previous post we discussed about finding square root using exponential operation.

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

You can watch the video on YouTube here.

Program on Github

SquareRoot – Code Visualization

Task :

To find square root of a given number.

Approach :

  • Read input number for which the square root is to be calculated using input()orraw_input().
  • Pass that number to sqrt method from Math module sqrt(num).
  • sqrt method will return the square root of the number passed.
  • Print the result.

Program :

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

print('The square root of %0.3f is %0.3f' % (num, math.sqrt(num)))

Output :

Square root of a number - programminginpython.com
Square root of a number – programminginpython.com

 

Square root of a number - programminginpython.com
Square root of a number – programminginpython.com

Program on Github

Online Python Compiler

Leave a Reply

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