Check if given number is perfect square | Python3 program for the above approach ; If ceil and floor are equal the number is a perfect square ; Driver code
import math NEW_LINE def checkperfectsquare ( x ) : NEW_LINE INDENT if ( math . ceil ( math . sqrt ( n ) ) == math . floor ( math . sqrt ( n ) ) ) : NEW_LINE INDENT print ( " perfect ▁ square " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " not ▁ a ▁ perfect ▁ square " ) NEW_LINE DEDENT DEDENT n = 49 NEW_LINE checkperfectsquare ( n ) NEW_LINE