Input Format
The first and only line contains the integer, .
Constraints
Output Format
Print lines, one corresponding to each .
Sample Input
5
Sample Output
0
1
4
9
16
Loops - Hacker Rank Solution
Problem Tester's code :
for i in range(int(raw_input())):
print i**2
n=int(input())
ReplyDeletefor i in range(n):
print(i**2)
so we dont have to mention negative integer
DeleteExample i<0
def is_leap(year):
Deleteif year % 400 == 0:
return True
elif year % 100 == 0:
return False
elif year % 400 == 0:
return True
elif year % 4 != 0:
return False
year = int(raw_input())
print is_leap(year)
You code is wrong bro
Deleteif year%4==0 and year%100!==0 or year%400==0:
Deletereturn True
else:
return False
n= int(input())
DeleteFor i in range(n):
Print (i**2)
n=int(input())
ReplyDeletefor i in range(n):
if i < n:
print(i**2)
for i in range(0,N):
ReplyDeleteprint (pow(i,2))
ReplyDeleteif __name__ == '__main__':
n = int(input())
for i in range(n):
print (i**2)
n=int(input())
ReplyDeletefor i in range(n):
if i < n:
print(i**2)
i = 0
ReplyDeleteN = 5
while i<N:
sum = i*i
i = i + 1
print(sum)
This is Shown wrong on HackerRank But On Pycharm i am getting the correct required output
i= 0
DeleteN = 5
while i<N:
sum = i*i
i = i + 1
print(sum)
you tipe the code in this process it was true
It is showing error in hackerrank because user is asked there to input the value of n. And here, you have provided the value of n.
DeleteI am not able to understand can it been explained line by line
ReplyDeleteif __name__ == '__main__':
ReplyDeleten = int(input())
count = -1
while n > 0:
count = count+1
power = count*count
n = n - 1
print(power)
The first and only line contains the integer, .
Constraints
n = 5
ReplyDeletei = 0
for i in range(n):
print(i * i)
e = i + 1
This would work perfectly 👍👍👍
n = int(input())
Deletei = 0
for i in range(n):
print(i * i)
e = i + 1
This is for all numbers.....
This is the most complete answer - passes all test cases...
Deleteif __name__ == '__main__':
ReplyDeleten = int(raw_input())
for i in range(int(n)):
print(i**2)
this is right code
if __name__ == '__main__':
ReplyDeleten = int(input())
i = 0
for i in range(n):
print(i * i)
e = i + 1
if __name__ == '__main__':
ReplyDeleten = int(input())
i = int
for i in range(0,n):
print(i**2)