Exercise 14
Write a python program that asks the user to enter an integer n and display whether this number is a perfect square or not.
Solution
1 2 3 4 5 6 7 8 9 10 11 |
# Ask user to enter an integer n n = int(input("Type the value of n: ")) # We use and initialize a counter j j = 0 for i in range(0,n): if(i**2 == n): j = j +1 if(j > 0): print("The integer ", n , " is a perfect square") else: print("the integer", n, "is not a perfect square") |
Younes Derfoufi
CRMEF OUJDA
Acheter sur Très Facile !
1 thought on “Solution Exercise 14 perfect square in Python”