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 (20)

PDF
Object reusability in python
Learnbay Datascience
 
PPTX
CubeIT Tech - Algorithms
Kirill Suslov
 
DOC
Question bank unit i
Rasi Manivannan
 
PDF
Wrapper classes
Ravi_Kant_Sahu
 
PPTX
Data Structure and Algorithms –Introduction.pptx
R S Anu Prabha
 
PDF
220 runtime environments
J'tong Atong
 
PPT
Data structures
Saurabh Mishra
 
PPT
wrapper classes
Rajesh Roky
 
PPTX
Java tutorial part 3
Mumbai Academisc
 
PPTX
Regular Expressions
Akhil Kaushik
 
PPTX
1909 BERT: why-and-how (CODE SEMINAR)
WarNik Chow
 
PDF
Namespaces
Sangeetha S
 
PPT
Abstract data types
Hoang Nguyen
 
PPTX
Lecture 10 semantic analysis 01
Iffat Anjum
 
PPT
Designing A Syntax Based Retrieval System03
Avelin Huo
 
PPT
Basic data-structures-v.1.1
BG Java EE Course
 
PPT
Ppt chapter06
Richard Styner
 
PPTX
Bert
Abdallah Bashir
 
PPTX
Introduction to Eclipse
Arpana Awasthi
 
PDF
Introduction java programming
Nanthini Kempaiyan
 
Object reusability in python
Learnbay Datascience
 
CubeIT Tech - Algorithms
Kirill Suslov
 
Question bank unit i
Rasi Manivannan
 
Wrapper classes
Ravi_Kant_Sahu
 
Data Structure and Algorithms –Introduction.pptx
R S Anu Prabha
 
220 runtime environments
J'tong Atong
 
Data structures
Saurabh Mishra
 
wrapper classes
Rajesh Roky
 
Java tutorial part 3
Mumbai Academisc
 
Regular Expressions
Akhil Kaushik
 
1909 BERT: why-and-how (CODE SEMINAR)
WarNik Chow
 
Namespaces
Sangeetha S
 
Abstract data types
Hoang Nguyen
 
Lecture 10 semantic analysis 01
Iffat Anjum
 
Designing A Syntax Based Retrieval System03
Avelin Huo
 
Basic data-structures-v.1.1
BG Java EE Course
 
Ppt chapter06
Richard Styner
 
Introduction to Eclipse
Arpana Awasthi
 
Introduction java programming
Nanthini Kempaiyan
 

Similar to 1 cs xii_python_functions_introduction _types of func (20)

PPTX
5 cs xii_python_functions _ passing str list tuple
SanjayKumarMahto1
 
PPTX
3 cs xii_python_functions _ parameter passing
SanjayKumarMahto1
 
PDF
Zero to Hero - Introduction to Python3
Chariza Pladin
 
PDF
Userdefined functions brief explaination.pdf
DeeptiMalhotra19
 
PDF
🐍⚡ “Python Panache: Code Like a Pro, Not a Programmer!”
yashikanigam1
 
PPTX
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
PPTX
pythonforaipythonforaipythonforaipython.pptx
mlakshmi28
 
PPTX
cbse class 12 Python Functions2 for class 12 .pptx
tcsonline1222
 
ODP
James Jesus Bermas on Crash Course on Python
CP-Union
 
PDF
functions-.pdf
MikialeTesfamariam
 
PPT
Python
Chetan Khanzode
 
PDF
summer training report on python
Shubham Yadav
 
PDF
Python_Unit_2.pdf
alaparthi
 
PPTX
python-fefedfasdgsgfahfdshdhunctions-190506123237.pptx
avishekpradhan24
 
PPTX
program fundamentals using python1 2 3 4.pptx
ibrahimsoryjalloh91
 
PDF
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
prasadmutkule1
 
PDF
Functions-.pdf
arvdexamsection
 
PDF
Using Python Libraries.pdf
SoumyadityaDey
 
PDF
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Tutort Academy
 
PDF
Top Python Online Training Institutes in Bangalore
SaagTechnologies
 
5 cs xii_python_functions _ passing str list tuple
SanjayKumarMahto1
 
3 cs xii_python_functions _ parameter passing
SanjayKumarMahto1
 
Zero to Hero - Introduction to Python3
Chariza Pladin
 
Userdefined functions brief explaination.pdf
DeeptiMalhotra19
 
🐍⚡ “Python Panache: Code Like a Pro, Not a Programmer!”
yashikanigam1
 
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
pythonforaipythonforaipythonforaipython.pptx
mlakshmi28
 
cbse class 12 Python Functions2 for class 12 .pptx
tcsonline1222
 
James Jesus Bermas on Crash Course on Python
CP-Union
 
functions-.pdf
MikialeTesfamariam
 
summer training report on python
Shubham Yadav
 
Python_Unit_2.pdf
alaparthi
 
python-fefedfasdgsgfahfdshdhunctions-190506123237.pptx
avishekpradhan24
 
program fundamentals using python1 2 3 4.pptx
ibrahimsoryjalloh91
 
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
prasadmutkule1
 
Functions-.pdf
arvdexamsection
 
Using Python Libraries.pdf
SoumyadityaDey
 
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Tutort Academy
 
Top Python Online Training Institutes in Bangalore
SaagTechnologies
 
Ad

Recently uploaded (20)

PPTX
Latest Features in Odoo 18 - Odoo slides
Celine George
 
PPTX
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Presentation: Climate Citizenship Digital Education
Karl Donert
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
PDF
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
Latest Features in Odoo 18 - Odoo slides
Celine George
 
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Presentation: Climate Citizenship Digital Education
Karl Donert
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
Ad

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