In this HackerRank Loops problem in python programming solution, we have given an integer n and we need to print the square of nonnegative integers that are less than the given input integers using the for a loop.

HackerRank Loops in python problem solution

HackerRank Loops in python problem solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
a = int(raw_input())

for i in range(0, a):
    print i*i

Problem solution in Python 3 programming.

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


Here in the above program, we are using the input function to get the value of variable n. and then we are using the for loop to print the square of values that are less than the variable n.