Loops Python - Hacker Rank Solution

Loops - Hacker Rank Solution


Problem Statement :

Task:

      The provided code stub reads an integer, n, from STDIN. For all non-negative integers, I <n, print i^2.

Example:

       n=3

       The list of non-negative integers that are less than n=3 is [0,1,2]. Print the square of each number on a separate line.

      0

      1

      4

Input Format:

     The first and only line contains the integer, n.

Constraints:

     1<=n<=20

Output Format:

     Print n lines, one corresponding to each i.


Solution:

if __name__ == '__main__':
n = int(input())
for i in range(n):
print(i*i)




Disclaimer:- 

The above hole problem statement is given by hackerrank.com but the solution is generated by the Hackerranksolution.site authority if any of the queries regarding this post or website fill the following contact form thank you.
Next Post Previous Post
No Comment
Add Comment
comment url