SlideShare une entreprise Scribd logo
1  sur  11
.
Class-XII Computer Science (083)
All the contents used as part of the slides are either self created or from the public domain or textbooks for Class XII.
This presentation is only used for leaning purpose only. Programs used in this presentation are based on Python 3.8.0.
Computational Thinking and Programming - 2
Working with Functions
S K Mahto, PGT (Computer Science)
J.N.V East Medinipur WB
Working with Functions
Working with
Functions
Topics to be covered
 Scope,
 Parameter passing,
 Mutable/immutable properties of data objects,
 Passing strings, lists, tuples, dictionaries to functions,
 Default parameters,
 Positional parameters,
 Return values,
 Functions using libraries: mathematical and string
functions.
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Introduction
What is Function? : A function is a group of statements which performs a
specific task.
A function can –
have its name ,
have its argument(s),
perform certain task,
return a result;
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Python Function Types
● Built-in functions
● Functions defined in modules / Modules
● User defined functions
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Python Function Types
● Built-in functions – These are pre-defined functions
and are always available for use. You have used some of
them – len(), type(), int(), input() etc.
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Python Function Types
● Functions defined in modules / Modules –
● A module is a file containing Python definitions (i.e. functions)
and statements.
● These functions can only be used when module is imported. For
example, if we want to use predefined functions inside a
module, say sqrt(), factorial(), we need to first import the
module math in our program.
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Python Function Types
● Functions defined in modules / Modules –
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Python Function Types
● User defined functions –
● These are defined by programmer. As programmers we can create our
own functions.
● To define a function keyword def is used.
● After the keyword comes an identifier i.e. name of the function,
followed by parenthesized list of parameters and the colon which
ends up the line.
● Next follows the block of statement(s) that are the part of function.
● return() statement exits and returns a value.
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Python Function Types
● User defined functions –
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Python Function Types
● User defined functions –
Presented by : S K Mahto, PGT Computer Science
Working with Functions
Introduction
Scope
parameter passing
mutable/immutable properties of
data objects
passing strings, lists, tuples,
dictionaries to functions,
default parameters
positional parameters
return values
functions using libraries:
mathematical and str
Defining Function & Calling a function
def fact(num):
f=1
for i in range(num,0,-1):
f=f*i
return(f)
print(fact(5))
Body of the
function
Name of
the
function
Argument of the function
Function call
OR
Calling function
Presented by : S K Mahto, PGT Computer Science
Keyword def is used
Function name - fact
Parameter – num
Body of function
return()
Here function calling ==>

Contenu connexe

Tendances

CubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsCubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsKirill Suslov
 
Data Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptxData Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptxR S Anu Prabha
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environmentsJ'tong Atong
 
1909 BERT: why-and-how (CODE SEMINAR)
1909 BERT: why-and-how (CODE SEMINAR)1909 BERT: why-and-how (CODE SEMINAR)
1909 BERT: why-and-how (CODE SEMINAR)WarNik Chow
 
Abstract data types
Abstract data typesAbstract data types
Abstract data typesHoang Nguyen
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Iffat Anjum
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Avelin Huo
 
Introduction to Eclipse
Introduction to Eclipse Introduction to Eclipse
Introduction to Eclipse Arpana Awasthi
 

Tendances (20)

Object reusability in python
Object reusability in pythonObject reusability in python
Object reusability in python
 
CubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsCubeIT Tech - Algorithms
CubeIT Tech - Algorithms
 
Question bank unit i
Question bank unit iQuestion bank unit i
Question bank unit i
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Data Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptxData Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptx
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
 
Data structures
Data structuresData structures
Data structures
 
wrapper classes
wrapper classeswrapper classes
wrapper classes
 
Java tutorial part 3
Java tutorial part 3Java tutorial part 3
Java tutorial part 3
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
1909 BERT: why-and-how (CODE SEMINAR)
1909 BERT: why-and-how (CODE SEMINAR)1909 BERT: why-and-how (CODE SEMINAR)
1909 BERT: why-and-how (CODE SEMINAR)
 
Namespaces
NamespacesNamespaces
Namespaces
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Ppt chapter06
Ppt chapter06Ppt chapter06
Ppt chapter06
 
Bert
BertBert
Bert
 
Introduction to Eclipse
Introduction to Eclipse Introduction to Eclipse
Introduction to Eclipse
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 

Similaire à CLASS-XII Functions

5 cs xii_python_functions _ passing str list tuple
5 cs xii_python_functions _ passing str list tuple5 cs xii_python_functions _ passing str list tuple
5 cs xii_python_functions _ passing str list tupleSanjayKumarMahto1
 
3 cs xii_python_functions _ parameter passing
3 cs xii_python_functions _ parameter passing3 cs xii_python_functions _ parameter passing
3 cs xii_python_functions _ parameter passingSanjayKumarMahto1
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Chariza Pladin
 
Userdefined functions brief explaination.pdf
Userdefined functions brief explaination.pdfUserdefined functions brief explaination.pdf
Userdefined functions brief explaination.pdfDeeptiMalhotra19
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonCP-Union
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham Yadav
 
Python_Unit_2.pdf
Python_Unit_2.pdfPython_Unit_2.pdf
Python_Unit_2.pdfalaparthi
 
Using Python Libraries.pdf
Using Python Libraries.pdfUsing Python Libraries.pdf
Using Python Libraries.pdfSoumyadityaDey
 
Top Python Online Training Institutes in Bangalore
Top Python Online Training Institutes in BangaloreTop Python Online Training Institutes in Bangalore
Top Python Online Training Institutes in BangaloreSaagTechnologies
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdfprasnt1
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
 
Programming in Civil Engineering_UNIT 2_NOTES
Programming in Civil Engineering_UNIT 2_NOTESProgramming in Civil Engineering_UNIT 2_NOTES
Programming in Civil Engineering_UNIT 2_NOTESRushikesh Kolhe
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2Prerna Sharma
 

Similaire à CLASS-XII Functions (20)

5 cs xii_python_functions _ passing str list tuple
5 cs xii_python_functions _ passing str list tuple5 cs xii_python_functions _ passing str list tuple
5 cs xii_python_functions _ passing str list tuple
 
3 cs xii_python_functions _ parameter passing
3 cs xii_python_functions _ parameter passing3 cs xii_python_functions _ parameter passing
3 cs xii_python_functions _ parameter passing
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
 
Userdefined functions brief explaination.pdf
Userdefined functions brief explaination.pdfUserdefined functions brief explaination.pdf
Userdefined functions brief explaination.pdf
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on Python
 
functions-.pdf
functions-.pdffunctions-.pdf
functions-.pdf
 
Python
PythonPython
Python
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Python_Unit_2.pdf
Python_Unit_2.pdfPython_Unit_2.pdf
Python_Unit_2.pdf
 
Functions-.pdf
Functions-.pdfFunctions-.pdf
Functions-.pdf
 
Using Python Libraries.pdf
Using Python Libraries.pdfUsing Python Libraries.pdf
Using Python Libraries.pdf
 
Top Python Online Training Institutes in Bangalore
Top Python Online Training Institutes in BangaloreTop Python Online Training Institutes in Bangalore
Top Python Online Training Institutes in Bangalore
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdf
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
 
Programming in Civil Engineering_UNIT 2_NOTES
Programming in Civil Engineering_UNIT 2_NOTESProgramming in Civil Engineering_UNIT 2_NOTES
Programming in Civil Engineering_UNIT 2_NOTES
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
 
Python functions
Python functionsPython functions
Python functions
 

Dernier

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Dernier (20)

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

CLASS-XII Functions

  • 1. . Class-XII Computer Science (083) All the contents used as part of the slides are either self created or from the public domain or textbooks for Class XII. This presentation is only used for leaning purpose only. Programs used in this presentation are based on Python 3.8.0. Computational Thinking and Programming - 2 Working with Functions S K Mahto, PGT (Computer Science) J.N.V East Medinipur WB
  • 2. Working with Functions Working with Functions Topics to be covered  Scope,  Parameter passing,  Mutable/immutable properties of data objects,  Passing strings, lists, tuples, dictionaries to functions,  Default parameters,  Positional parameters,  Return values,  Functions using libraries: mathematical and string functions. Presented by : S K Mahto, PGT Computer Science
  • 3. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Introduction What is Function? : A function is a group of statements which performs a specific task. A function can – have its name , have its argument(s), perform certain task, return a result; Presented by : S K Mahto, PGT Computer Science
  • 4. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Python Function Types ● Built-in functions ● Functions defined in modules / Modules ● User defined functions Presented by : S K Mahto, PGT Computer Science
  • 5. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Python Function Types ● Built-in functions – These are pre-defined functions and are always available for use. You have used some of them – len(), type(), int(), input() etc. Presented by : S K Mahto, PGT Computer Science
  • 6. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Python Function Types ● Functions defined in modules / Modules – ● A module is a file containing Python definitions (i.e. functions) and statements. ● These functions can only be used when module is imported. For example, if we want to use predefined functions inside a module, say sqrt(), factorial(), we need to first import the module math in our program. Presented by : S K Mahto, PGT Computer Science
  • 7. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Python Function Types ● Functions defined in modules / Modules – Presented by : S K Mahto, PGT Computer Science
  • 8. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Python Function Types ● User defined functions – ● These are defined by programmer. As programmers we can create our own functions. ● To define a function keyword def is used. ● After the keyword comes an identifier i.e. name of the function, followed by parenthesized list of parameters and the colon which ends up the line. ● Next follows the block of statement(s) that are the part of function. ● return() statement exits and returns a value. Presented by : S K Mahto, PGT Computer Science
  • 9. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Python Function Types ● User defined functions – Presented by : S K Mahto, PGT Computer Science
  • 10. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Python Function Types ● User defined functions – Presented by : S K Mahto, PGT Computer Science
  • 11. Working with Functions Introduction Scope parameter passing mutable/immutable properties of data objects passing strings, lists, tuples, dictionaries to functions, default parameters positional parameters return values functions using libraries: mathematical and str Defining Function & Calling a function def fact(num): f=1 for i in range(num,0,-1): f=f*i return(f) print(fact(5)) Body of the function Name of the function Argument of the function Function call OR Calling function Presented by : S K Mahto, PGT Computer Science Keyword def is used Function name - fact Parameter – num Body of function return() Here function calling ==>