×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python Function Classification Based on Parameters and Return Values

Last Updated : April 24, 2025

There are following types of the Python functions based on their parameters and return values:

  1. Function with no argument and no return value
  2. Function with no argument but return value
  3. Function with argument and no return value
  4. Function with arguments and return value

1) Function with no argument and no return value

These types of Python functions do not take any argument and do not return any value.

Example

def sum():
    a = int(input("Enter A: "))
    b = int(input("Enter B: "))
    c=a+b
    print("Sum    :", c)

def main():
    sum()

if __name__=="__main__":
    main()

Output

Enter A: 10
Enter B: 20
Sum    : 30

2) Function with no argument but return value

These types of Python functions do not take any argument but return a value.

Example

def sum():
    a = int(input("Enter A: "))
    b = int(input("Enter B: "))
    c=a+b
    return c

def main():
    c = sum()
    print("Sum    :",c)

if __name__=="__main__":
    main()

Output

Enter A: 10
Enter B: 20
Sum    : 30

3) Function with argument and no return value

These types of Python functions have the arguments but do not return any value.

Example

def sum(a,b):
    c=a+b
    print("Sum    :", c)

def main():
    a = int(input("Enter A: "))
    b = int(input("Enter B: "))
    sum(a,b)

if __name__=="__main__":
    main()

Output

Enter A: 10
Enter B: 20
Sum    : 30

4) Function with arguments and return value

These types of Python functions have the arguments and also return a value.

Example

def sum(a,b):
    c=a+b
    return c

def main():
    a = int(input("Enter A: "))
    b = int(input("Enter B: "))
    c = sum(a,b)
    print("Sum    :",c)

if __name__=="__main__":
    main()

Output

Enter A: 10
Enter B: 20
Sum    : 30

Python Function Classifications Exercise

Select the correct option to complete each statement about function classifications in Python.

  1. Functions that are defined inside a class are called ___.
  2. Functions that do not belong to a class and are defined using the def keyword are called ___.
  3. Functions like len(), print(), and range() are examples of ___ functions in Python.

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.