Python for Data Science: Chapter 2: Functions and Files

Python: Return Values in Function

The value can be returned from a function using the keyword return.

Return Values

• The value can be returned from a function using the keyword return. For example

• Syntax

    return [expression_list]

Uses of return statement

1) The return statement is used to return a value from a function to the caller.

2) The return statement is sometimes used to return a control back to the caller.

Example:1

Write a Python program to compute area of circle using function and a return statement.

Solution :

def areaCircle(r):

      PI= 3.14

      result=PI*r*r

      print("The result of circle: ")

      return result

Output

In [12]:

areaCircle (10)

The result of circle:

Out[12]: 314.0


 

Python for Data Science: Chapter 2: Functions and Files : Tag: Computer Programming, Python, Data Science : - Python: Return Values in Function


Python for Data Science: Chapter 2: Functions and Files



Under Subject


Python for Data Science

AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Applied Physics (CSIE) II

PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Digital Principles and Computer Organization

CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electrical and Electronics Engineering

EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Python for Data Science

AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Python for Data Science - Laboratory

AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation