Examveda

What does the return statement do in a function?

A. It terminates the function immediately

B. It outputs a value from the function

C. It defines a loop condition

D. It defines an if-statement condition

Answer: Option B

Solution (By Examveda Team)

In a function, the return statement is used to output a value from the function.
When a return statement is encountered in a function, it immediately exits the function and sends back the specified value to the caller. This allows the function to produce a result or output that can be used in other parts of the program. The returned value can be assigned to variables, used in expressions, or passed as arguments to other functions. The return statement is essential for functions to be able to provide results or perform computations that yield outputs.

This Question Belongs to Python Program >> Introduction To Python

Join The Discussion

Related Questions on Introduction to Python