SlideShare a Scribd company logo
Name: Sampad Kar
Student Code: BWU/BTA/22/225
Course Name: Introduction To Python
Programming
Course Code: BSCM303
Group: D
Session: 2023-24
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.
Types Of Functions
Built-in
Functions
User-defined
functions
Anonymous
Functions
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()
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.
• .
Basic Syntax
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.
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.
What is anonymous function
• An anonymous function in Python is one that has
no name when it is defined.
Example: Lambda Function
it is a process in which a function calls itself
directly or indirectly.
Thank
You

More Related Content

Similar to Python Functions

Similar to Python Functions (20)

Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
 
10. sub program
10. sub program10. sub program
10. sub program
 
SENG 208 Week -5 Python Functions Presentation
SENG 208 Week -5 Python Functions PresentationSENG 208 Week -5 Python Functions Presentation
SENG 208 Week -5 Python Functions Presentation
 
Functions
FunctionsFunctions
Functions
 
5. Functions in C.pdf
5. Functions in C.pdf5. Functions in C.pdf
5. Functions in C.pdf
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
Python functions
Python functionsPython functions
Python functions
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Basics concept of Python : An infographic view!
Basics concept of Python : An infographic view!Basics concept of Python : An infographic view!
Basics concept of Python : An infographic view!
 
Computer Sc..pptx
Computer Sc..pptxComputer Sc..pptx
Computer Sc..pptx
 
Functions in python What are functions. Types of functions.pptx
Functions in python What are functions. Types of functions.pptxFunctions in python What are functions. Types of functions.pptx
Functions in python What are functions. Types of functions.pptx
 
Oop.pptx
Oop.pptxOop.pptx
Oop.pptx
 
Monolithic and Procedural Programming
Monolithic and Procedural ProgrammingMonolithic and Procedural Programming
Monolithic and Procedural Programming
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
 
functions.pptx
functions.pptxfunctions.pptx
functions.pptx
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 
C- language Lecture 4
C- language Lecture 4C- language Lecture 4
C- language Lecture 4
 
FUNCTIONS IN R PROGRAMMING.pptx
FUNCTIONS IN R PROGRAMMING.pptxFUNCTIONS IN R PROGRAMMING.pptx
FUNCTIONS IN R PROGRAMMING.pptx
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 

More from Sampad Kar

Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating System
Sampad Kar
 
Logical Equivalence | Propositional Logic | Discrete Mathematics
Logical Equivalence | Propositional Logic | Discrete MathematicsLogical Equivalence | Propositional Logic | Discrete Mathematics
Logical Equivalence | Propositional Logic | Discrete Mathematics
Sampad Kar
 
Turing Machine | Theory Of Computation | Formal Language and Automata Theory
Turing Machine | Theory Of Computation | Formal Language and Automata TheoryTuring Machine | Theory Of Computation | Formal Language and Automata Theory
Turing Machine | Theory Of Computation | Formal Language and Automata Theory
Sampad Kar
 
Constructor In Java | Object Oriented Programming
Constructor In Java | Object Oriented ProgrammingConstructor In Java | Object Oriented Programming
Constructor In Java | Object Oriented Programming
Sampad Kar
 

More from Sampad Kar (13)

Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating System
 
Logical Equivalence | Propositional Logic | Discrete Mathematics
Logical Equivalence | Propositional Logic | Discrete MathematicsLogical Equivalence | Propositional Logic | Discrete Mathematics
Logical Equivalence | Propositional Logic | Discrete Mathematics
 
Turing Machine | Theory Of Computation | Formal Language and Automata Theory
Turing Machine | Theory Of Computation | Formal Language and Automata TheoryTuring Machine | Theory Of Computation | Formal Language and Automata Theory
Turing Machine | Theory Of Computation | Formal Language and Automata Theory
 
Constructor In Java | Object Oriented Programming
Constructor In Java | Object Oriented ProgrammingConstructor In Java | Object Oriented Programming
Constructor In Java | Object Oriented Programming
 
Data Structure - Stacks
Data Structure - StacksData Structure - Stacks
Data Structure - Stacks
 
Basic Logic Gates
Basic Logic GatesBasic Logic Gates
Basic Logic Gates
 
Reduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC)Reduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC)
 
Variation Of Parameter (Differential Equations)
Variation Of Parameter (Differential Equations)Variation Of Parameter (Differential Equations)
Variation Of Parameter (Differential Equations)
 
Probability Distribution - Binomial, Exponential and Normal
Probability Distribution - Binomial, Exponential and NormalProbability Distribution - Binomial, Exponential and Normal
Probability Distribution - Binomial, Exponential and Normal
 
Carnot Engine - Thermodynamics
Carnot Engine - ThermodynamicsCarnot Engine - Thermodynamics
Carnot Engine - Thermodynamics
 
Central Tendency - Mean, Median and Mode
Central Tendency - Mean, Median and ModeCentral Tendency - Mean, Median and Mode
Central Tendency - Mean, Median and Mode
 
LAW OF VARIABLE PROPORTIONS
LAW OF VARIABLE PROPORTIONSLAW OF VARIABLE PROPORTIONS
LAW OF VARIABLE PROPORTIONS
 
2D-Arrays
2D-Arrays2D-Arrays
2D-Arrays
 

Recently uploaded

Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
YibeltalNibretu
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 

Recently uploaded (20)

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Forest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFForest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDF
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 

Python Functions

  • 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. • .
  • 8.
  • 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.