Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Python

Python | Function classifications on the basis of parameters and return values



Python function classifications: Here, we are going to learn about the python function classifications based on their parameters and return values.
Submitted by Pankaj Singh, on October 11, 2018

There are following types of the 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

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

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

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

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





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.