SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
FUNCTION RETURNS
THE RETURN STATEMENT
• Used to end execution of a function
• Can be placed anywhere in a function
• Statements that follow the return statement will not be executed
• Can be used to prevent abnormal termination of an application
• A function can return a value or expression back to the statement that called the
function.
• Ex.
• x = random.random()
• val = math.sqrt(16)
• In a function that returns a value, the return statement can be used to return a value
from the function to the point of call.
• assign it to a variable
• send it to print
• use it in an expression
DECLARING A RETURN FUNCTION
• Code:
Declaring a Basic Function:
def functionName ():
Function Body
return valueToReturn
• Question: What do you believe will happen if write a return
statement with no return value?
• Question: What concept does this remind you of?
CALLING A FUNCTION
• Functions just like variables need to be called in order to be invoked
• Code:
Calling a Function:
functionName ()
o Ex.
val = rtnFnCall()
print(rtnFnCall())
val = rtnFnCall() * 5
FUNCTION WITH RETURN EXAMPLE

More Related Content

PPS
Introduction to php 5
PPTX
Stack and queue -polish notations
PPT
Removal Of Recursion
PPTX
Infix to postfix conversion
PPTX
Tail Recursion in data structure
PPTX
Infix-Postfix expression conversion
PDF
Please look at the problems I am having which are listed below: Write a prog...
PPTX
Functions
Introduction to php 5
Stack and queue -polish notations
Removal Of Recursion
Infix to postfix conversion
Tail Recursion in data structure
Infix-Postfix expression conversion
Please look at the problems I am having which are listed below: Write a prog...
Functions

What's hot (20)

PPT
Infix to Postfix Conversion Using Stack
PPTX
Loop control structure
PPTX
Function Parameters
PPTX
Loop c++
PDF
computer notes - Conversion from infix to postfix
PDF
C++ control structure
PPTX
Working of while loop
DOCX
Check the output of the following code then recode it to eliminate fu
PPTX
09 advanced c#
PPT
Programming loop
PPTX
Cold fusion best practice
PDF
computer notes - Evaluating postfix expressions
PPT
Looping statements in Java
PDF
The Ring programming language version 1.7 book - Part 24 of 196
PDF
Oot practical
PDF
selection structures
PPT
Looping in c++
DOCX
Stack - Operations and Applications
PDF
Unit II chapter 4 Loops in C
Infix to Postfix Conversion Using Stack
Loop control structure
Function Parameters
Loop c++
computer notes - Conversion from infix to postfix
C++ control structure
Working of while loop
Check the output of the following code then recode it to eliminate fu
09 advanced c#
Programming loop
Cold fusion best practice
computer notes - Evaluating postfix expressions
Looping statements in Java
The Ring programming language version 1.7 book - Part 24 of 196
Oot practical
selection structures
Looping in c++
Stack - Operations and Applications
Unit II chapter 4 Loops in C
Ad

Similar to Returning Data (20)

PPTX
Python_Functions_Modules_ User define Functions-
PPTX
Functions in Python Programming Language
PPTX
functions.pptx
PPTX
04. WORKING WITH FUNCTIONS-2 (1).pptx
PPTX
JNTUK python programming python unit 3.pptx
PPTX
use of Functions to write python program.pptx
PPTX
Function in Python function in python.pptx
PPTX
Understanding Python Programming Language -Functions
PDF
Notes5
PDF
functions notes.pdf python functions and opp
PDF
PPTX
Working with functions the minumum ppt.pptx
PPTX
Decided to go to the 65 and the value of the number
PPTX
Function Returns
PDF
Functions in Pythons UDF and Functions Concepts
PPTX
Working with functions.pptx. Hb.
PPTX
functions new.pptx
PPTX
Python Details Functions Description.pptx
PPTX
Py-slides-3 easyforbeginnerspythoncourse.pptx
PPTX
Lecture 5 Functions all about business categories
Python_Functions_Modules_ User define Functions-
Functions in Python Programming Language
functions.pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
JNTUK python programming python unit 3.pptx
use of Functions to write python program.pptx
Function in Python function in python.pptx
Understanding Python Programming Language -Functions
Notes5
functions notes.pdf python functions and opp
Working with functions the minumum ppt.pptx
Decided to go to the 65 and the value of the number
Function Returns
Functions in Pythons UDF and Functions Concepts
Working with functions.pptx. Hb.
functions new.pptx
Python Details Functions Description.pptx
Py-slides-3 easyforbeginnerspythoncourse.pptx
Lecture 5 Functions all about business categories
Ad

More from primeteacher32 (20)

PPT
Software Development Life Cycle
PPTX
Variable Scope
PPTX
Intro to Functions
PPTX
Introduction to GUIs with guizero
PPTX
Function Parameters
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
Intro to Functions
Introduction to GUIs with guizero
Function Parameters
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)

PPT
notes_Lecture2 23l3j2 dfjl dfdlkj d 2.ppt
PPT
pwm ppt .pdf long description of pwm....
PPT
Woman as Engineer and Technicians in the field of Clinical & Biomedical Engin...
PPTX
E-commerce Security and Fraud Issues and Protection
PPTX
Coordination Compuch flasks didiinds.pptx
PDF
LSR CASEBOOK 2024-25.pdf. very nice casbook
PPT
ppt-of-extraction-of-metals-12th-1.pptb9
PPTX
STS CHAP 4 human development as reflected
PDF
Acne presentation and homeopathy treatment
PPT
2- CELL INJURY L1 Medical (2) gggggggggg
PPTX
430838499-Anaesthesiiiia-Equipmenooot.pptx
PPTX
employee on boarding for jobs for freshers try it
PPTX
mathsportfoliomanvi-211121071838 (1).pptx
PDF
Beyond the Lab Coat - Perjalanan Karier di Dunia Pasca-Fisika S1
PPTX
_Dispute Resolution_July 2022.pptxmhhghhhh
PPTX
D1basicstoloopscppforbeginnersgodoit.pptx
PDF
CollegePresentation.pdf hsjsisjsjsjsssoo
PPT
NO000387 (1).pptsbsnsnsnsnsnsnsmsnnsnsnsjsnnsnsnsnnsnnansnwjwnshshshs
PPTX
Core Characteristics and Abilities of an Effective Teacher_0.pptx
PDF
Shopify Store Management_ Complete Guide to E-commerce Success.pdf
notes_Lecture2 23l3j2 dfjl dfdlkj d 2.ppt
pwm ppt .pdf long description of pwm....
Woman as Engineer and Technicians in the field of Clinical & Biomedical Engin...
E-commerce Security and Fraud Issues and Protection
Coordination Compuch flasks didiinds.pptx
LSR CASEBOOK 2024-25.pdf. very nice casbook
ppt-of-extraction-of-metals-12th-1.pptb9
STS CHAP 4 human development as reflected
Acne presentation and homeopathy treatment
2- CELL INJURY L1 Medical (2) gggggggggg
430838499-Anaesthesiiiia-Equipmenooot.pptx
employee on boarding for jobs for freshers try it
mathsportfoliomanvi-211121071838 (1).pptx
Beyond the Lab Coat - Perjalanan Karier di Dunia Pasca-Fisika S1
_Dispute Resolution_July 2022.pptxmhhghhhh
D1basicstoloopscppforbeginnersgodoit.pptx
CollegePresentation.pdf hsjsisjsjsjsssoo
NO000387 (1).pptsbsnsnsnsnsnsnsmsnnsnsnsjsnnsnsnsnnsnnansnwjwnshshshs
Core Characteristics and Abilities of an Effective Teacher_0.pptx
Shopify Store Management_ Complete Guide to E-commerce Success.pdf

Returning Data

  • 2. THE RETURN STATEMENT • Used to end execution of a function • Can be placed anywhere in a function • Statements that follow the return statement will not be executed • Can be used to prevent abnormal termination of an application • A function can return a value or expression back to the statement that called the function. • Ex. • x = random.random() • val = math.sqrt(16) • In a function that returns a value, the return statement can be used to return a value from the function to the point of call. • assign it to a variable • send it to print • use it in an expression
  • 3. DECLARING A RETURN FUNCTION • Code: Declaring a Basic Function: def functionName (): Function Body return valueToReturn • Question: What do you believe will happen if write a return statement with no return value? • Question: What concept does this remind you of?
  • 4. CALLING A FUNCTION • Functions just like variables need to be called in order to be invoked • Code: Calling a Function: functionName () o Ex. val = rtnFnCall() print(rtnFnCall()) val = rtnFnCall() * 5