Loops HackerRank Solutions In Python

Check Tutorial tab to know how to to solve.

Task

The provided code stub reads and integer, n, from STDIN. For all non-negative integers i < n, print 12.

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.

014

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.

Sample Input 0

5

Sample Output 0

014916

Solution to HackerRank Loop In Python

In this problem, we are to write a program that loops through the range of a given integer and print out the square of all integers less than the given.

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

NOTE: The problem solved above, Loops, was generated by HackerRank and the solution was brought by the admin of  CodingSolutions for educational purpose. Got any issues with the code? Ask your questions in the comment box and I shall attend to it.

Comments