Q. Is return statement optional? Compare and comment on the following two return statements:
return
return val
Answer =
The return
statement is optional only when the function is void or we can say that when
the function does not return a value. A function that returns a value must have
at least one return statement.
From the given two return statements, the statement:
return
Is not returning any value. Rather, it returns
the control to caller along with empty value None. And the statement:
return val
is returning the control to caller along with the value contained in variable
val.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )