Python Program to Find the Square Root of Number

Python Program to Find the Square Root of Number

Python program to find square root of number; In this tutorial, you will learn how to find the square root of number in python programming.

The square root of a number is a number that, when multiplied by itself, equals the desired value. So, for example, the square root of 49 is 7 (7×7=49). The process of multiplying a number times itself is called squaring.

Using the following formula, you can write a python program to find the square root of number:

x2 = y 

x = ±√y

Python Program to Find the Square Root of Number

Follow the following algorithm to write a python program to find the square root of number:

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

Find square root of a number in python without using sqrt

Follow the below steps and write a program to find square root of number in Python:

  • Allow the User to input the number.
  • Calculate square root with this formula sqrt = num ** 0.5.
  • 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

Follow the below steps and write program to find square of a number using sqrt() function in python:

  • Import math module in program
  • Allow the User to input any number
  • Calculate 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 Programs

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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