As a newbie programmer

Square of squares @ Dcoder

Dcoder icon

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

Publish0x Publish0x

Reward the author with $0.01 in crypto, and earn yourself as you read!

20% to author / 80% to me.
Rewards are FREE. Publish0x pays them, not you.

Page not displaying correctly?