Test Index

CBSE Class 12 Computer Science 2025 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 22 of 37
Marks: +1, -0
What does the return statement do in a function ? Explain with the help of an example.
Solution:  
Concept:
The return statement ends the execution of a function and sends a value (the result) back to the statement that called the function. The returned value can be stored in a variable, printed or used in an expression. Statements written after return inside the function are not executed. A function with no return (or with a bare return) returns None.
Example:
def Add(A, B):
return A + B # sends the sum back to the caller
Result = Add(5, 3) # returned value 8 is stored in Result
print(Result)
Output:
8
Here Add(5, 3) computes 5+3=85 + 3 = 8, the return statement passes 8 back to the caller, and it is stored in Result.
© examsnet.com
Advertisements
Go to Question: