0% found this document useful (0 votes)
2 views1 page

Understanding Python Functions

The document explains key concepts related to Python functions, including the purpose of the return statement, the difference between global and local variables, the definition of recursive functions, and the use of lambda functions. It highlights that the return statement sends a result back to the caller, global variables are accessible throughout the program while local variables are confined to their function, and recursive functions call themselves to solve problems. Additionally, it describes lambda functions as small anonymous functions that can take multiple arguments but only contain one expression.

Uploaded by

preetamsalunke0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Understanding Python Functions

The document explains key concepts related to Python functions, including the purpose of the return statement, the difference between global and local variables, the definition of recursive functions, and the use of lambda functions. It highlights that the return statement sends a result back to the caller, global variables are accessible throughout the program while local variables are confined to their function, and recursive functions call themselves to solve problems. Additionally, it describes lambda functions as small anonymous functions that can take multiple arguments but only contain one expression.

Uploaded by

preetamsalunke0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like