Computer Science
Write a short program to check whether square root of a number is prime or not.
Python
Python Control Flow
37 Likes
Answer
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
Answered By
20 Likes
Related Questions
Write a short program to input a digit and print it in words.
Write a short program to print first n odd numbers in descending order.
Write a short program to print the following series :
(i) 1 4 7 10 ………. 40.
(ii) 1 -4 7 -10 ………. -40Write a program to input length of three sides of a triangle. Then check if these sides will form a triangle or not.
(Rule is: a+b>c;b+c>a;c+a>b)