Program to print non square numbers | Python 3 program to print first n non - square numbers . ; Function to check perfect square ; function to print all non square number ; variable which stores the count ; Not perfect square ; Driver code
import math NEW_LINE def isPerfectSquare ( n ) : NEW_LINE INDENT if ( n < 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT root = round ( math . sqrt ( n ) ) NEW_LINE return ( n == root * root ) NEW_LINE DEDENT def printnonsquare ( n ) : NEW_LINE INDENT count = 0 NEW_LINE i = 1 NEW_LINE while ( count < n ) : NEW_LINE INDENT if ( isPerfectSquare ( i ) == False ) : NEW_LINE INDENT print ( i , end = " ▁ " ) NEW_LINE count = count + 1 NEW_LINE DEDENT i = i + 1 NEW_LINE DEDENT DEDENT n = 10 NEW_LINE printnonsquare ( n ) NEW_LINE