Python Functions Assignment
1. What is the purpose of return statement in python Functions? What happens if a function does n
The return statement in a Python function is used to send a result back to the caller. It ends the
execution of the function and gives back a value. If a function does not have a return statement, it
returns 'None' by default.
2. What is the difference between global and local variables?
Global variables are defined outside any function and can be accessed anywhere in the program.
Local variables are defined inside a function and can only be used within that function. Changes to
local variables do not affect global variables unless 'global' keyword is used.
3. What is recursive function?
A recursive function is a function that calls itself to solve smaller instances of the same problem. It
must have a base case to stop the recursion, otherwise it will result in infinite recursion.
4. What is a lambda function in python?
A lambda function is a small anonymous function defined using the 'lambda' keyword. It can have
any number of arguments but only one expression. Example: lambda x, y: x + y