Q. What is following code doing? What would it print for input as 3?


n = int (route "Enter an integer : "))

if n < 1 :

    print ("invalid value")

else :

    for i in range (1, n + 1) :

        print (i * i)



Answer =

It is doing that, if the given number is greater than 1 then it will give the output that square of number to the ‘n’ terms.

Output is: -

Enter an integer : 3

1
4
9

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post