SlideShare a Scribd company logo
2
Most read
4
Most read
5
Most read
Function Parameters
Sending Data into a Function
 Can pass values into a function at time of call:
c = pow(a, b)
time.sleep(2)
 Values passed to function are arguments
 Variables in a function that hold the values
passed as arguments are parameters
A Function with a Parameter Variable
def displayValue(num):
print("The value is ", num)
The integer variable num is a parameter.
It accepts any value passed to the function.
Parameter Passing Example
(4)
Function Call Notes
 Value of argument is copied into parameter when
the function is called
 A parameter’s scope is the function which uses it
 Function can have multiple parameters
Passing Multiple Arguments
When calling a function and passing multiple arguments:
 The number of arguments in the call must match the prototype and
definition
 The first argument will be used to initialize the first parameter, the
second argument to initialize the second parameter, etc.
Passing Multiple Arguments Example
Passing Data by Value
 Pass by value: when an argument is passed to a function, its value is
copied into the parameter.
 Changes to the parameter in the function do not affect the value of the
argument
 Example: val = 5
evenOrOdd(val)
 evenOrOdd can change variable num, but it will have no effect on variable
val
5
val
argument in
calling function
5
num
parameter in
evenOrOdd function
Returning Multiple Values
 The python return statement unlike other languages can return
multiple values
 Code: Function call with multiple return values
 var1, var2, … = function()
Functions as Parameters
 Parameters can be functions
 Remember a function can return a value (transitive property)

More Related Content

PPTX
Functions in python
PPTX
Pass by value and pass by reference
PPTX
Python ppt
PPTX
Variables in python
PDF
Python Flow Control
PDF
Python-01| Fundamentals
PPT
Event+driven+programming key+features
PDF
Methods in Java
Functions in python
Pass by value and pass by reference
Python ppt
Variables in python
Python Flow Control
Python-01| Fundamentals
Event+driven+programming key+features
Methods in Java

What's hot (20)

PPTX
Function C programming
PPTX
Input processing and output in Python
PDF
Datatypes in python
PPTX
Functions in python slide share
PPTX
Passing an Array to a Function (ICT Programming)
PDF
Tuples in Python
PPT
C++ Function
PPTX
Python Functions
PPTX
PPTX
Types of function call
PPT
Functions in c++
PPTX
classes and objects in C++
PPT
FUNCTIONS IN c++ PPT
PDF
Python programming : Control statements
PPTX
Functions in c language
PDF
Operator overloading
PPT
pseudo code basics
Function C programming
Input processing and output in Python
Datatypes in python
Functions in python slide share
Passing an Array to a Function (ICT Programming)
Tuples in Python
C++ Function
Python Functions
Types of function call
Functions in c++
classes and objects in C++
FUNCTIONS IN c++ PPT
Python programming : Control statements
Functions in c language
Operator overloading
pseudo code basics
Ad

Similar to Function Parameters (20)

PPTX
Function Parameters
PPTX
Lecture 08.pptx
PPT
functions _
PPT
functions modules and exceptions handlings.ppt
PDF
Python Function.pdf
PPTX
Python Functions.pptx
PPT
Python programming variables and comment
PPTX
Python functions PYTHON FUNCTIONS1234567
PPT
Py-Slides-3 difficultpythoncoursefforbeginners.ppt
PDF
3-Python Functions.pdf in simple.........
PDF
Python functions
PPTX
3 cs xii_python_functions _ parameter passing
PPT
Powerpoint presentation for Python Functions
PPT
python slides introduction interrupt.ppt
PDF
Userdefined functions brief explaination.pdf
PPTX
Functions in Python with all type of arguments
PPTX
UNIT 3 python.pptx
PPTX
Python programming - Functions and list and tuples
PPTX
JNTUK python programming python unit 3.pptx
PDF
Unit 1-Part-5-Functions and Set Operations.pdf
Function Parameters
Lecture 08.pptx
functions _
functions modules and exceptions handlings.ppt
Python Function.pdf
Python Functions.pptx
Python programming variables and comment
Python functions PYTHON FUNCTIONS1234567
Py-Slides-3 difficultpythoncoursefforbeginners.ppt
3-Python Functions.pdf in simple.........
Python functions
3 cs xii_python_functions _ parameter passing
Powerpoint presentation for Python Functions
python slides introduction interrupt.ppt
Userdefined functions brief explaination.pdf
Functions in Python with all type of arguments
UNIT 3 python.pptx
Python programming - Functions and list and tuples
JNTUK python programming python unit 3.pptx
Unit 1-Part-5-Functions and Set Operations.pdf
Ad

More from primeteacher32 (20)

PPT
Software Development Life Cycle
PPTX
Variable Scope
PPTX
Returning Data
PPTX
Intro to Functions
PPTX
Introduction to GUIs with guizero
PPTX
Nested Loops
PPT
Conditional Loops
PPTX
Introduction to Repetition Structures
PPTX
Input Validation
PPTX
Windows File Systems
PPTX
Nesting Conditionals
PPTX
Conditionals
PPT
Intro to Python with GPIO
PPTX
Variables and Statements
PPTX
Variables and User Input
PPT
Intro to Python
PPTX
Raspberry Pi
PPT
Hardware vs. Software Presentations
PPTX
Block chain security
PPTX
Software Development Life Cycle
Variable Scope
Returning Data
Intro to Functions
Introduction to GUIs with guizero
Nested Loops
Conditional Loops
Introduction to Repetition Structures
Input Validation
Windows File Systems
Nesting Conditionals
Conditionals
Intro to Python with GPIO
Variables and Statements
Variables and User Input
Intro to Python
Raspberry Pi
Hardware vs. Software Presentations
Block chain security

Recently uploaded (20)

PDF
Blue-Modern-Elegant-Presentation (1).pdf
PPTX
Discovering the LMA Course by Tim Han.pptx
DOC
field study for teachers graduating samplr
PDF
HR Jobs in Jaipur: 2025 Trends, Banking Careers & Smart Hiring Tools
PPTX
ESD MODULE-5hdbdhbdbdbdbbdbdbbdndbdbdbdbbdbd
PPTX
Principles of Inheritance and variation class 12.pptx
PDF
MCQ Practice CBT OL Official Language 1.pptx.pdf
PPTX
PMP (Project Management Professional) course prepares individuals
PPTX
The Stock at arrangement the stock and product.pptx
PPTX
_+✅+JANUARY+2025+MONTHLY+CA.pptx current affairs
DOCX
How to Become a Criminal Profiler or Behavioural Analyst.docx
PPTX
退学买新西兰毕业证(WelTec毕业证书)惠灵顿理工学院毕业证国外证书制作
PPTX
1751884730-Visual Basic -Unitj CS B.pptx
PDF
Prostaglandin E2.pdf orthoodontics op kharbanda
PPTX
Cerebral_Palsy_Detailed_Presentation.pptx
PPT
APPROACH TO DEVELOPMENTALlllllllllllllllll
PPT
BCH3201 (Enzymes and biocatalysis)-JEB (1).ppt
PPTX
Definition and Relation of Food Science( Lecture1).pptx
PPT
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
PPTX
Nervous_System_Drugs_PPT.pptxXXXXXXXXXXXXXXXXX
Blue-Modern-Elegant-Presentation (1).pdf
Discovering the LMA Course by Tim Han.pptx
field study for teachers graduating samplr
HR Jobs in Jaipur: 2025 Trends, Banking Careers & Smart Hiring Tools
ESD MODULE-5hdbdhbdbdbdbbdbdbbdndbdbdbdbbdbd
Principles of Inheritance and variation class 12.pptx
MCQ Practice CBT OL Official Language 1.pptx.pdf
PMP (Project Management Professional) course prepares individuals
The Stock at arrangement the stock and product.pptx
_+✅+JANUARY+2025+MONTHLY+CA.pptx current affairs
How to Become a Criminal Profiler or Behavioural Analyst.docx
退学买新西兰毕业证(WelTec毕业证书)惠灵顿理工学院毕业证国外证书制作
1751884730-Visual Basic -Unitj CS B.pptx
Prostaglandin E2.pdf orthoodontics op kharbanda
Cerebral_Palsy_Detailed_Presentation.pptx
APPROACH TO DEVELOPMENTALlllllllllllllllll
BCH3201 (Enzymes and biocatalysis)-JEB (1).ppt
Definition and Relation of Food Science( Lecture1).pptx
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
Nervous_System_Drugs_PPT.pptxXXXXXXXXXXXXXXXXX

Function Parameters

  • 2. Sending Data into a Function  Can pass values into a function at time of call: c = pow(a, b) time.sleep(2)  Values passed to function are arguments  Variables in a function that hold the values passed as arguments are parameters
  • 3. A Function with a Parameter Variable def displayValue(num): print("The value is ", num) The integer variable num is a parameter. It accepts any value passed to the function.
  • 5. Function Call Notes  Value of argument is copied into parameter when the function is called  A parameter’s scope is the function which uses it  Function can have multiple parameters
  • 6. Passing Multiple Arguments When calling a function and passing multiple arguments:  The number of arguments in the call must match the prototype and definition  The first argument will be used to initialize the first parameter, the second argument to initialize the second parameter, etc.
  • 8. Passing Data by Value  Pass by value: when an argument is passed to a function, its value is copied into the parameter.  Changes to the parameter in the function do not affect the value of the argument  Example: val = 5 evenOrOdd(val)  evenOrOdd can change variable num, but it will have no effect on variable val 5 val argument in calling function 5 num parameter in evenOrOdd function
  • 9. Returning Multiple Values  The python return statement unlike other languages can return multiple values  Code: Function call with multiple return values  var1, var2, … = function()
  • 10. Functions as Parameters  Parameters can be functions  Remember a function can return a value (transitive property)