+ 11
1). explain it to me I do not understand
What is the highest number output by this code? def print_nums(x): for i in range(x): print(i) return print_nums(10)
8 Answers
+ 5
So, why print_nums(10) is written here
+ 4
Thanks a lot for explaining
+ 2
But here i not defined
+ 2
Ans will be 0 becoz the return statement is in for loop and the loop exits in the first run only
+ 1
So, how we know value
+ 1
print_nums (10)
Is calling the already defined "print_nums" function on the number "10"
Its asking for the result of print_nums(x) if the x is replaced with 10
+ 1
Your result will be 0 because:
You will be immediately thrown out of a function as soon as the python execute the return statement.
+ 1
((So, why print_nums(10) is written here)))
It's because..."print_nums(x)" has been initially defined at the top,...
So "print_nums(10)", was meant to input 10 into the "print_nums(x)" function in place of "(x)"
but the return statement made it loop only
once...
And the code has been intentionally made not to be straight -forward