Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views2 pages

Function Classification Python

Functions in Python are classified into four types based on their arguments and return values: No Arguments, No Return Value; Arguments, No Return Value; No Arguments, Return Value; and Arguments and Return Value. Each type serves different purposes, from displaying messages to performing calculations. Understanding these classifications aids in writing modular and reusable code.

Uploaded by

ennadisolra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Function Classification Python

Functions in Python are classified into four types based on their arguments and return values: No Arguments, No Return Value; Arguments, No Return Value; No Arguments, Return Value; and Arguments and Return Value. Each type serves different purposes, from displaying messages to performing calculations. Understanding these classifications aids in writing modular and reusable code.

Uploaded by

ennadisolra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Classification of Functions in Python

Classify Functions Based on Arguments and Return Values

In Python, functions are classified into four types based on whether they accept arguments and return values:

1. No Arguments, No Return Value

- These functions do not take any input and do not return any output.

- Used when the function performs a task like displaying a message.

Example:

def greet():

print("Hello!")

greet()

2. Arguments, No Return Value

- These functions take arguments but do not return any value.

- Used when data is passed to the function, and only internal processing or display is needed.

Example:

def greet(name):

print("Hello", name)

greet("Ravi")

3. No Arguments, Return Value

- These functions do not take any input but return a value.

- Useful when the function generates or fetches data without external input.

Example:

def get_number():

return 100

x = get_number()

4. Arguments and Return Value

- These functions accept input arguments and return a result.


Classification of Functions in Python

- Most commonly used type for calculations or data processing.

Example:

def add(a, b):

return a + b

sum = add(10, 20)

Conclusion:

These four types allow flexibility in function usage depending on the need for inputs and outputs. Proper use helps in

modular, reusable, and clean code design.

You might also like