Dcoder icon

Square of squares @ Dcoder

By Lochard | As a newbie programmer | 26 Jun 2023


Problem: You have a hobby of building blocks. You are especially fond of building blocks that are squares. And what you even like more, is to arrange them into a square of square building blocks! /n However, sometimes, you are unable to achieve this goal of yours. If you just had a way to know, whether you're currently working in vain… Wait! That's it! You just have to check if your number of building blocks is a perfect square.

Input: Input is an integer, determine if it's a square number or not.

Output: Output should be YES if the number is a perfect square otherwise NO.

Constraints: Input is an integer (it can be a negative number too)

Sample Input: 25

Sample Output: 

YES

i = int(input())
if i < 0:
  print('NO')
print('YES' if int(i**.5)**2 == i else 'NO')

How do you rate this article?

1


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.