Python Program to check the square root of a number is prime or not
In this program, You will learn how to check the square root of a number is prime or not in Python.
49 => 7 : Prime
64 => 4 : not prime
Example: How to check the square root of a number is prime or not in Python.
import math
x = int(input("Enter a number:"))
f = (math.sqrt(x))
print("Square root is :", f)
n = int(f)
p = 1
i = 2
while i < n:
if n % i == 0:
p = 0
break
i = i + 1
if p == 1:
print("Number is prime:", n)
else:
print("Number is not prime:", n)
Output:
Enter a number:49
Square root is : 7.0
Number is prime: 7