What is following code doing? What would it print for input as 3 ?
n = int (input( "Enter an integer:" )) if n< 1:
print ("invalid value")
else:
for i in range(1, n + 1):
print (i*i)
Answers
Answered by
12
Answer:
it is if_else statement, it is used to check weather the given argument is - true Or false, compair the given argument etc.
Explanation:
let n be 3
so,
3<1.........condition true
it will give the output "invalid value" if 3 is entered as input
else it will print
(1,3+1)
=4 ......... i
so the output will be 4*4 =16
Answered by
0
Answer:
1
4
9
Hope this answer helps you
Similar questions