Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

Default Arguments in python

 

Function with default arguments

 

Python default arguments are evaluated once when the function is defined, not each time the function is called.

 

def power(x,n=2):

return x**n

Call a function -

ans=power(3)

ans=power(3,5)

 

Example :

def sum(a,b=3)

print('sum =',a+b)

print('a=',a)

print('b=',b)

sum(5)

O/P -

sum =8

a =5

b =3

 

Another Example :

def sum(a=1,b=3)

print('sum =',a+b)

print('a=',a)

print('b=',b)

sum()

O/P -

sum =4

a =1

b =3

FAQs

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere