Use arguments in python function

Use arguments in python function

Instructor-svgAl-Mamun Sarkar
Mar 25 , 2020

Use argument in python function. The following code shows how to use arguments in a python function. 

def func(a, b, c):
    print("a is : %d" % a)
    print("b is : %d" % b)
    print("c is : %d" % c)
    return a + b + c


print("sum is %d" % func(10, 15, 20))

print(func(b=10, c=15, a=20))


def add(a, b=10):
    return a + b


print("Add is %d" % add(5))

 

Output:

a is : 10
b is : 15
c is : 20
sum is 45
a is : 20
b is : 10
c is : 15
45
Add is 15

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram