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
Ok
ReplyDelete: )
DeleteThank you <33
ReplyDeleteHow it become
ReplyDelete1
4
9(how 9 came here can you explain?)
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )