SlideShare a Scribd company logo
.
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 ==>

More Related Content

What's hot

Object reusability in python
Object reusability in pythonObject reusability in python
Object reusability in python
Learnbay Datascience
 
CubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsCubeIT Tech - Algorithms
CubeIT Tech - Algorithms
Kirill Suslov
 
Question bank unit i
Question bank unit iQuestion bank unit i
Question bank unit i
Rasi Manivannan
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
Ravi_Kant_Sahu
 
Data Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptxData Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptx
R S Anu Prabha
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
J'tong Atong
 
Data structures
Data structuresData structures
Data structures
Saurabh Mishra
 
wrapper classes
wrapper classeswrapper classes
wrapper classes
Rajesh Roky
 
Java tutorial part 3
Java tutorial part 3Java tutorial part 3
Java tutorial part 3
Mumbai Academisc
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
Akhil Kaushik
 
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
 
Namespaces
NamespacesNamespaces
Namespaces
Sangeetha S
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Hoang Nguyen
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03
Avelin Huo
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
BG Java EE Course
 
Ppt chapter06
Ppt chapter06Ppt chapter06
Ppt chapter06
Richard Styner
 
Bert
BertBert
Introduction to Eclipse
Introduction to Eclipse Introduction to Eclipse
Introduction to Eclipse
Arpana Awasthi
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
Nanthini Kempaiyan
 

What's hot (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
 

Similar to 1 cs xii_python_functions_introduction _types of func

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
SanjayKumarMahto1
 
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
SanjayKumarMahto1
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
 
Userdefined functions brief explaination.pdf
Userdefined functions brief explaination.pdfUserdefined functions brief explaination.pdf
Userdefined functions brief explaination.pdf
DeeptiMalhotra19
 
cbse class 12 Python Functions2 for class 12 .pptx
cbse class 12 Python Functions2 for class 12 .pptxcbse class 12 Python Functions2 for class 12 .pptx
cbse class 12 Python Functions2 for class 12 .pptx
tcsonline1222
 
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
CP-Union
 
functions-.pdf
functions-.pdffunctions-.pdf
functions-.pdf
MikialeTesfamariam
 
Python
PythonPython
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
Shubham Yadav
 
Python_Unit_2.pdf
Python_Unit_2.pdfPython_Unit_2.pdf
Python_Unit_2.pdf
alaparthi
 
Functions-.pdf
Functions-.pdfFunctions-.pdf
Functions-.pdf
arvdexamsection
 
Using Python Libraries.pdf
Using Python Libraries.pdfUsing Python Libraries.pdf
Using Python Libraries.pdf
SoumyadityaDey
 
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
SaagTechnologies
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdf
prasnt1
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
MohammedAlYemeni1
 
Python. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdfPython. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdf
prasenjitghosh1998
 
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
Adam Getchell
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
Karthik Prakash
 
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
Rushikesh Kolhe
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
Emertxe Information Technologies Pvt Ltd
 

Similar to 1 cs xii_python_functions_introduction _types of func (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
 
cbse class 12 Python Functions2 for class 12 .pptx
cbse class 12 Python Functions2 for class 12 .pptxcbse class 12 Python Functions2 for class 12 .pptx
cbse class 12 Python Functions2 for class 12 .pptx
 
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
 
Python. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdfPython. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdf
 
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
 

Recently uploaded

220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
Kalna College
 
Creative Restart 2024: Mike Martin - Finding a way around “no”
Creative Restart 2024: Mike Martin - Finding a way around “no”Creative Restart 2024: Mike Martin - Finding a way around “no”
Creative Restart 2024: Mike Martin - Finding a way around “no”
Taste
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
RandolphRadicy
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
Kalna College
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
adjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammaradjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammar
7DFarhanaMohammed
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
MJDuyan
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 

Recently uploaded (20)

220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
 
Creative Restart 2024: Mike Martin - Finding a way around “no”
Creative Restart 2024: Mike Martin - Finding a way around “no”Creative Restart 2024: Mike Martin - Finding a way around “no”
Creative Restart 2024: Mike Martin - Finding a way around “no”
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
adjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammaradjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammar
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 

1 cs xii_python_functions_introduction _types of func

  • 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 ==>