SlideShare a Scribd company logo
2
Most read
3
Most read
11
Most read
Python Programming
Unit – II (Part III)
(Lecture 12)
Fruitful functions
Return values
Incremental
development
Nested functions
Fruitful functions
Lecture 12 Lecture 13
Return values
Incremental
development
Nested functions
Boolean functions
More recursion
Checking types
Fruitful functions
Lecture 12
Return values
Incremental
development
Nested functions
• As soon as a return statement executes, the function terminates
without executing any subsequent statements.
• Code that appears after a return statement is called dead code.
Return values
Return values
Function:
Statement 3
Statement 4
Statement 5
Statement 6
….
….
Program:
Statement 1
Statement 2
Call function
Statement 7
Call function
….
….
Executed
Function without return
Return values
Function:
Statement 3
Statement 4
return
Statement 5
Statement 6
….
….
Program:
Statement 1
Statement 2
Call function
Statement 7
Call function
….
….
Executed
Function with return
Dead code
Fruitful functions
Lecture 12
Return values
Incremental
development
Nested functions
Incremental development
• Larger functions are difficult to debug.
• To deal with complex programs, use incremental development.
• The goal of incremental development is to avoid long debugging
sessions by adding and testing only a small amount of code at a time.
Incremental development
• Suppose you want to find the distance between
two points, given by the coordinates (x1, y1) and
(x2, y2).
• By the Pythagorean theorem, the distance is:
Fruitful functions
Lecture 12
Return values
Incremental
development
Nested functions
Nested functions
• We can call
one function
from within
another. This
ability is
called
composition.
Fruitful functions
Lecture 12
Return values
Incremental
development
Nested functions
Python Programming
Unit – II (Part III)
(Lecture 13)
Fruitful functions
Boolean functions More recursion Checking types
Fruitful functions
Lecture 12 Lecture 13
Return values
Incremental
development
Nested functions
Boolean functions
More recursion
Checking types
Fruitful functions
Lecture 13
Boolean functions
More recursion
Checking types
Boolean functions
• Functions can return
Booleans.
• For hiding complicated
tests inside functions.
Fruitful functions
Lecture 13
Boolean functions
More recursion
Checking types
More recursion
More recursion
Fruitful functions
Lecture 13
Boolean functions
More recursion
Checking types
Checking types
Checking types
• We can use the
built-in function
isinstance to
verify the type
of the argument.
Fruitful functions
Lecture 13
Boolean functions
More recursion
Checking types

More Related Content

PPT
Pipeline hazard
PPTX
Finite State Machine.ppt.pptx
PPTX
Interrupts on 8086 microprocessor by vijay kumar.k
PPTX
Basics of Vhdl
PPT
FPGA Configuration
PPSX
8085 Interfacing with I/O Devices or Memory
PPTX
Functions in Python
PPTX
Timing and control circuit
Pipeline hazard
Finite State Machine.ppt.pptx
Interrupts on 8086 microprocessor by vijay kumar.k
Basics of Vhdl
FPGA Configuration
8085 Interfacing with I/O Devices or Memory
Functions in Python
Timing and control circuit

What's hot (20)

PPT
Booths Multiplication Algorithm
PPTX
Logical instructions (and, or, xor, not, test)
PPTX
Python Lambda Function
PDF
Life cycle-of-a-thread
PPT
Data manipulation instructions
PDF
Ch8 (1) morris mano
PPTX
INLINE FUNCTION IN C++
PPTX
Python Conditionals and Functions
PPTX
Python Functions
PDF
Python-List comprehension
PDF
Numba: Array-oriented Python Compiler for NumPy
PPT
Program control
PPT
Instruction set
PPT
Memory allocation in c
PPTX
Data flow model -Lecture-4
PPTX
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
PDF
0_Digital IC Pin Details and Functional Tables.pdf
PPTX
Accessing I/O Devices
Booths Multiplication Algorithm
Logical instructions (and, or, xor, not, test)
Python Lambda Function
Life cycle-of-a-thread
Data manipulation instructions
Ch8 (1) morris mano
INLINE FUNCTION IN C++
Python Conditionals and Functions
Python Functions
Python-List comprehension
Numba: Array-oriented Python Compiler for NumPy
Program control
Instruction set
Memory allocation in c
Data flow model -Lecture-4
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
0_Digital IC Pin Details and Functional Tables.pdf
Accessing I/O Devices
Ad

Similar to Python Programming | JNTUA | UNIT 2 | Fruitful Functions | (20)

PPTX
Introduction to python programming ( part-2 )
PPTX
2.4 Fruitful Functions.pptx2.4 Fruitful Functions.pptx
PPTX
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
PPTX
Functional programming in python
PDF
Functional programming in python
PPTX
ForLoopandUserDefinedFunctions.pptx
PPTX
UNIT – 3.pptx for first year engineering
PPTX
Pythonlearn-04-Functions (1).pptx
PPTX
Python Learn Function with example programs
PDF
Notes5
PPTX
Python Lecture 4
PPTX
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
PDF
Python Programming Module 3 (2).pdf
DOCX
Functions.docx
DOCX
Python unit 3 and Unit 4
PDF
Python cheatsheat.pdf
PPTX
Python Session - 4
PPTX
DATA TYPES IN PYTHON jesjdjdjkdkkdk.pptx
PPTX
Working with functions.pptx. Hb.
PPTX
JNTUK python programming python unit 3.pptx
Introduction to python programming ( part-2 )
2.4 Fruitful Functions.pptx2.4 Fruitful Functions.pptx
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Functional programming in python
Functional programming in python
ForLoopandUserDefinedFunctions.pptx
UNIT – 3.pptx for first year engineering
Pythonlearn-04-Functions (1).pptx
Python Learn Function with example programs
Notes5
Python Lecture 4
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Programming Module 3 (2).pdf
Functions.docx
Python unit 3 and Unit 4
Python cheatsheat.pdf
Python Session - 4
DATA TYPES IN PYTHON jesjdjdjkdkkdk.pptx
Working with functions.pptx. Hb.
JNTUK python programming python unit 3.pptx
Ad

More from FabMinds (20)

PPTX
Python Programming | JNTUA | UNIT 3 | Lists |
PPTX
Python Programming | JNTUA | UNIT 3 | Strings |
PPTX
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
PPTX
Python Programming | JNTUA | UNIT 2 | Case Study |
PPTX
Application layer protocols
PPTX
Internet connectivity
PPTX
Introduction for internet connectivity (IoT)
PPTX
web connectivity in IoT
PPTX
message communication protocols in IoT
PPTX
web communication protocols in IoT
PPTX
introduction for web connectivity (IoT)
PPTX
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
PPTX
Data enrichment
PPTX
Communication technologies
PPTX
M2M systems layers and designs standardizations
PPTX
Business models for business processes on IoT
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 4
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 1 & 2
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUA | UNIT 3 | Lists |
Python Programming | JNTUA | UNIT 3 | Strings |
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
Python Programming | JNTUA | UNIT 2 | Case Study |
Application layer protocols
Internet connectivity
Introduction for internet connectivity (IoT)
web connectivity in IoT
message communication protocols in IoT
web communication protocols in IoT
introduction for web connectivity (IoT)
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Data enrichment
Communication technologies
M2M systems layers and designs standardizations
Business models for business processes on IoT
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 1 & 2
Python Programming | JNTUK | UNIT 1 | Lecture 3

Recently uploaded (20)

PPTX
master seminar digital applications in india
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Insiders guide to clinical Medicine.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
RMMM.pdf make it easy to upload and study
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Pharma ospi slides which help in ospi learning
master seminar digital applications in india
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
O7-L3 Supply Chain Operations - ICLT Program
Microbial diseases, their pathogenesis and prophylaxis
Insiders guide to clinical Medicine.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
102 student loan defaulters named and shamed – Is someone you know on the list?
RMMM.pdf make it easy to upload and study
Abdominal Access Techniques with Prof. Dr. R K Mishra
Final Presentation General Medicine 03-08-2024.pptx
Cell Types and Its function , kingdom of life
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
01-Introduction-to-Information-Management.pdf
Pharma ospi slides which help in ospi learning

Python Programming | JNTUA | UNIT 2 | Fruitful Functions |