codescracker


python

Python Program to Find Square Root of Number



« Previous Program Next Program »


Find Square Root of Number in Python

To find square root of any number in python, you have to ask from user to enter a number to find and print square root of that number as output as shown in the program given below.

Python Programming Code to Find Square Root of Number

Following python program ask from user to enter a number to find the square root of that number and then finally will print the square root as output:

# Python Program - Find Square Root of a Number

print("Enter 'x' for exit.");
num = input("Enter a number: ");
if num == 'x':
    exit();
else:
    number = float(num);
    number_sqrt = number ** 0.5;
    print("Square Root of %0.2f is %0.2f" %(number, number_sqrt));

Here is the sample run of the above python program to illustrate how to find square root of a number:

This is the sample output asking from user to enter a number to find its square root:

find square root of number python

Now enter a number say 25. As the square root of 25 is 5, then here is the output you will see:

square root of number python

Below is the same program on python shell:

python find square root of number

Program Video with Compile and Run


« Previous Program Next Program »








Tools
Calculator

Quick Links
Signup - Login - Give Online Test