CBSE Class 11 Computer Science
Question 131 of 161
Flow of Control — Question 8
Back to all questions 8
Question Question 8
Write a short program to check whether square root of a number is prime or not.
Solution
import math
n = int(input("Enter a number: "))
sr = math.sqrt(n)
c = 0
for i in range(1, int(sr + 1)) :
if (sr % i == 0) :
c += 1
if c == 2 :
print("Square root is prime")
else :
print("Square root is not prime")Output
Enter a number: 49
Square root is prime