This document provides information about functions in Python programming. It defines what a function is, why they are important for organization, readability and reusability. It describes different types of functions including built-in functions, user-defined functions, and anonymous functions. It explains how to use and define built-in functions, user-defined functions, and anonymous functions. It also discusses local and global variables as well as recursion.
1. Name: Sampad Kar
Student Code: BWU/BTA/22/225
Course Name: Introduction To Python
Programming
Course Code: BSCM303
Group: D
Session: 2023-24
2.
3. What is a function?
• a function is a sequence of program instructions
that performs a specific task, packaged as a unit.
This unit can then be used in programs wherever
that particular task should be performed.
Why functions are important?
• Functions in programming are essential for
organization, readability, and reusability. They break
down tasks, making code clear and modular.
Functions simplify debugging, enhance flexibility,
and ensure efficient development.
5. What are built-in functions?
• A built-in function is a function that is already available
in a programming language, application, or another tool.
Built-in functions are pre-defined in the programming
language's library.
How to use built-in functions?
• To use a built-in function, simply call it with the
appropriate arguments, like this:
function_name(argument1, argument2).
Examples
• print(), len(),
sum(),max(),list(),str(),pow(),sqrt(),ord(),chr(),reverse(),
isnum(),isalpha()
6. What are user-defined functions
• User defined functions in Python are functions
that are written by the user. They allow the user to
define custom logic that can be used to perform
specific tasks.
What are user-defined functions
• In Python, a def keyword is used to declare user-
defined functions.
• An indented block of statements follows the
function name and arguments which contains the
body of the function.
• .
9. A return statement is used to end the execution of the
function call and “returns” the result (value of the
expression following the return keyword) to the caller.
10. Local Variables
• Local variables are those that are initialized within a
function and are unique to that function. It cannot be
accessed outside of the function. Let’s look at how to
make a local variable.
Global Variables
• Global variables are the ones that are defined and
declared outside any function and are not specified to
any function. They can be used by any part of the
program.
11.
12. What is anonymous function
• An anonymous function in Python is one that has
no name when it is defined.
Example: Lambda Function
13. it is a process in which a function calls itself
directly or indirectly.