I'm totally new to python. I want to write a program which checks whether a number is squared or not. my code:
import math
T = int(input())
while T >= 0:
num = int(input())
sqrt = int(math.sqrt(num))
if sqrt * sqrt == num:
print('1')
else:
print('0')
T = T - 1
the code is working correctly in my IDE(pycharm community 2017) but it gets a runtime error as you see in online IDEs (on geeksforgeeks ide):
Traceback (most recent call last):
File "/home/043265f1cbdf257ecc20a7579588a4a4.py", line 5, in <module>
num = int(input())
EOFError: EOF when reading a line
Change it to:
while T > 0:
You are requesting 6 numbers if you compare for >=
and your example only provides 5.
Maybe better:
import math
for _ in range(int(input)):
num = int(input())
sqrt = int(math.sqrt(num))
if sqrt * sqrt == num:
print('1')
else:
print('0')
and remove the T